Menu

#385 Weird mapping - can't find syntax

open
nobody
5
2013-01-30
2013-01-30
Maksim Volf
No

Trying to map a String to a deep entry like this:
a.b[0].value, where a has no set for b. The only way to change b is to call a get on it and add, so something like this needs to occur:
<mapping>
<class-a>Source</class-a>
<class-b>Destination</class-b>
<field custom-converter="com.StringToNotStringConverter"><!-- the com.NotString has an empty constructor and setValue( String ) method -->
<a>plainFieldA</a><!-- this is java.lang.String -->
<b set-method="deepFieldA.getTheBList().add(com.NotString)">deepFieldA.theBList[0].value</b>
<b-hint>com.TypeOfBList</b-hint>
</field>
</mapping>

Basically, there main problem I see is that the custom set method needs to call 2 methods in a chain and I can't seem to find the right syntax how to make that work.
Or maybe there's a better way.
Please advise.

Also, is there a way to pass the Destination field value to the Converter so that I could operate on it? Its seems to always be null.

Thanks.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB