Hi,
I am trying to use JAXB objects instead of normal POJOs.
I am not able to use lazy-loading for a one-to-many association because JAXB invokes the getter method of collections from the setter method which makes Hibernate think that I have invoked the getter method manually and it loads all the collections
There is a one-to-many relationship between CalendarTemplate and DailyProfile.
This is my parent object mapping file:
<class
name="amazon.scheduleddelivery.deliverycalendar.vo.impl.CalendarTemplateVOImpl"
table="CALENDAR_TEMPLATE"
dynamic-update="true"
dynamic-insert="true"
>
<bag
name="dailyProfiles"
inverse="true"
cascade="all"
order-by="DAILY_PROFILE_ID asc"
lazy="true"
>
<key>
<column name="CALENDAR_TEMPLATE_ID" not-null="true"/>
</key>
<one-to-many
class="amazon.scheduleddelivery.deliverycalendar.vo.impl.DailyProfileVOImpl"
/>
</bag>
</class>
Here is the setter method code generated by JAXB
public void setDailyProfiles(java.util.List theDailyProfiles) {
java.util.List draft = new java.util.ArrayList();
if (null == theDailyProfiles) {
this.unsetDailyProfiles();
} else {
draft.addAll(theDailyProfiles);
java.util.List proxy = this.getDailyProfiles();
proxy.clear();
proxy.addAll(draft);
}
}
In the above code, getDailyProfiles() is invoked because of which Hibernate loads the collections automatically. Is there a way either in Hibernate or JAXB to overcome this behaviour?
Thanks,
Neel.
|