Hi,
in my other topic
https://forum.hibernate.org/viewtopic.php?f=1&t=1009053 i tried to explain what i wanted and actually kinda solved it. but for some of my data i need to use collections which are actually a single data. i worked the way around by changing getters and setters like below but is it possible to make bag return a class i want instead of a collection (or is there anything else that does it)
here is bag:
Code:
<bag name="displayHeader" inverse="true" cascade="all" lazy="false" where="typ = 2 and object_id = 1">
<key column="template_id" not-null="true" />
<one-to-many class="com.overteam.framework.persistent.NewsletterTemplateSettingsData" not-found="ignore" />
</bag>
here is way i changed my getter and setter:
Code:
public List<NewsletterTemplateSettingsData> getDisplayHeader(){
List<NewsletterTemplateSettingsData> list = new LinkedList<NewsletterTemplateSettingsData>();
list.add(displayHeader);
return list;
}
public NewsletterTemplateSettingsData getDisplayHeaderObject() {
return displayHeader;
}
public void setDisplayHeader(Object displayHeader) {
if(displayHeader.getClass().equals(NewsletterTemplateSettingsData.class))
this.displayHeader = (NewsletterTemplateSettingsData) displayHeader;
else if(displayHeader.getClass().equals(PersistentBag.class)){
List<NewsletterTemplateSettingsData> list = (List<NewsletterTemplateSettingsData>) displayHeader;
this.displayHeader = list != null && list.size() > 0 ? list.get(0) : null;
}
}
but to keep getters and setters in normal way