I know it has to be a really basic hibernate question, well, my problem is that I have a pojo like this one:<br><br>class Pojo {<br><br>Integer id;<br>TypeA foo;<br>TypeB zas;<br>... getters and setters....<br><br><br>}<br>
<br>class TypeA {<br><br>Integer id;<br>String description;<br>... getters and setters....<br><br>}<br><br><br>class TypeB {<br><br>Integer id;<br>String description;<br>... getters and setters....<br><br>}<br><br><br>and I have two mappings:<br>
<br><br><hibernate-mapping ><br> <class name="Pojo"<br> table="pojo_table"><br><br> <id column="pojo_id" name="id" type="int"<br> unsaved-value="0"><br>
<generator class="native" /><br> </id><br><br> <property name="foo" class="TypeA" column="pojo_foo" /><br> <br> <property name="zas" class="TypeB" column="pojo_zas" /><br>
<br> </class><br><br> <class name="TypeA"<br> table="typea_table"><br><br> <id column="typea_id" name="id" type="int"<br> unsaved-value="0"><br>
<generator class="native" /><br> </id><br><br> <property name="description" class="string" column="description" /><br> <br> </class><br>
<br></hibernate-mapping><br><br>But as you can see there is no TypeB mapping, because this value is being set in the service layer by a web service query, but I just want to persist the id of the returned object (TypeB). thus I want something like to transform cell values for TypeB (the id) and the object itself.<br>
<br><br><br>public class TypeBResolver{<br><br>public Integer getAsCellValue() {<br> TypeB d = (TypeB) getValue();<br> if (d == null) {<br> return null;<br> }<br> return d.getId();<br>}<br><br>public TypeB resolvCellValueForPojo(Integer s) {<br>
if (s != null) {<br><br>return typeBService.getB(s);<br><br>} else {return null}<br><br>}<br><br clear="all"><br>-- <br>Jaime Hablutzel<br> <br>(tildes omitidas intencionalmente) <br>