I have added a collection descriptor
<collection-descriptor name="addresses" element-class-ref="Adress" auto-update="true" auto-delete="true">
<inverse-foreignkey field-ref="login"/> </collection-descriptor>
and he returns both addresses.
I tried to modify my getters and setters for addresses to set homeAddress and workAddress, but I tested this and noticed that they are not invoked (why should they? (*grml*))
So I added a function assignAddresses(), which is invoked by the DAO getUser method.
public void addressAssignment() { Iterator i = this.adresses.iterator(); while (i.hasNext()) {
Adress address = (Address) i.next();
if ("home".equals(adress.getType())) this.homeAddress = address; if ("work".equals(adress.getType())) this.workAddress = address; } }
Now I have to take care that every setHomeAddress also modifies the collection (because I don't think that getAddresses() is invoked by ojb either ;) )
May be I implement a query costomizer who filters the addresses like described in the advanced mapping tutorial:
<collection-descriptor name="homeAddressCollection" element-class-ref="Address" auto-update="true" auto-delete="true">
<inverse-foreignkey field-ref="login"/>
<query-customizer class="AddressQueryCustomizer"> <attribute attribute-name="type" attribute-value="home" /> </query-customizer> </collection-descriptor>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]