Skip to content
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
Closed

Update mode does not apply to subSet #67

BenoitCharret opened this issue Oct 30, 2015 · 3 comments
Labels
Milestone

Comments

@BenoitCharret
Copy link

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
Copy link
Collaborator

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
Copy link
Author

Hi,

the snapshot build solve the issue.

Thanks

@BenoitCharret
Copy link
Author

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants