New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mode does not apply to subSet #67

Closed
BenoitCharret opened this Issue Oct 30, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@BenoitCharret

BenoitCharret commented Oct 30, 2015

Hi,
I want to map a bean in update mode. I define a Custom mapper for sublist (with an update mode too).
In that case, selma generate update mode for the wrong case.
Let see an example here : https://github.com/BenoitCharret/selma-test/tree/case_3

public class MySubMapper {

public List<AnotherSubElement> anotherSubElements(String element){
    ...
}

public List<AnotherSubElement> anotherSubElements(String element,List<AnotherSubElement> elements){
    ....
}

@Mapper(
withCustomFields = {
@field({"element", "infos"})
},
withCustom = {MySubMapper.class}
)

public interface MyMapper {

ToA asA(FromA fromA);

ToA asA(FromA fromA,ToA toA);

}

The generated code gives :

public final com.test.to.ToA asA(com.test.from.FromA in) {
com.test.to.ToA out = null;
if (in != null) {
out = new com.test.to.ToA();
out.setInfos(customMapperMySubMapper.anotherSubElements(in.getElement(), out.getInfos()));

@override
public final com.test.to.ToA asA(com.test.from.FromA in, com.test.to.ToA out) {
if (in != null) {
if (out == null) {
out = new com.test.to.ToA();
}
out.setInfos(customMapperMySubMapper.anotherSubElements(in.getElement()));

I thought that on the first case, the call should be out.setInfos(customMapperMySubMapper.anotherSubElements(in.getElement()));

and on the second (update mode)
out.setInfos(customMapperMySubMapper.anotherSubElements(in.getElement(), out.getInfos()));

regards

slemesle added a commit that referenced this issue Nov 5, 2015

@slemesle

This comment has been minimized.

Show comment
Hide comment
@slemesle

slemesle Nov 5, 2015

Got it there is a bug in hashcode from the TypeMirror class of JSR 269 :p. This was causing Selma not handling both custom mapping methods as the same Type pair.

Snapshot build should now be fixed for this buggy behavior.

slemesle commented Nov 5, 2015

Got it there is a bug in hashcode from the TypeMirror class of JSR 269 :p. This was causing Selma not handling both custom mapping methods as the same Type pair.

Snapshot build should now be fixed for this buggy behavior.

@BenoitCharret

This comment has been minimized.

Show comment
Hide comment
@BenoitCharret

BenoitCharret Nov 6, 2015

Hi,

the snapshot build solve the issue.

Thanks

BenoitCharret commented Nov 6, 2015

Hi,

the snapshot build solve the issue.

Thanks

@BenoitCharret

This comment has been minimized.

Show comment
Hide comment
@BenoitCharret

BenoitCharret Nov 17, 2015

Hi,

Can you made a release for the last fix ?

Regards

BenoitCharret commented Nov 17, 2015

Hi,

Can you made a release for the last fix ?

Regards

@slemesle slemesle added the bug label Nov 18, 2015

@slemesle slemesle added this to the 0.13 milestone Nov 18, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment