i will be specific as i can,so i want just ask for litle help with modification of this hbm.xml file
I have this file in my hibernate mappings
<hibernate-mapping>
<class name="sk.bantip.hotel.server.dao.book.Dealer" table="book_dealer">
<id column="idBook_dealer" name="id" type="java.lang.Long">
<generator class="identity" />
</id>
<many-to-one name="domain" column="idMain_domain"
not-null="true" class="sk.bantip.hotel.server.dao.main.Domain" />
<many-to-one name="activeData" column="idBook_dealerData"
class="sk.bantip.hotel.server.dao.book.DealerData" />
<set name="historyData" inverse="true">
<key column="idBook_dealer" />
<one-to-many class="sk.bantip.hotel.server.dao.book.DealerData" />
</set>
<property name="status" not-null="false" />
</class>
and this is associations:
<hibernate-mapping>
<class name="sk.bantip.hotel.server.dao.book.DealerData" table="book_dealerData">
<id column="idBook_dealerData" name="id" type="java.lang.Long">
<generator class="identity" />
</id>
<property name="name" not-null="true"/>
<property name="registration" not-null="true"/>
<property name="taxNumber" not-null="true"/>
<property name="timestamp" not-null="true" />
<property name="authorUserId" column="idAuthor" not-null="true" />
<many-to-one name="dealer" column="idBook_dealer"
not-null="true" class="sk.bantip.hotel.server.dao.book.Dealer" />
<property name="channel" not-null="false">
<type name="sk.bantip.core.enums.GenericEnumUserType">
<param name="enumClass">sk.bantip.hotel.server.dao.book.Channel</param>
<param name="identifierMethod">getValue</param>
<param name="valueOfMethod">getByCode</param>
</type>
</property>
<property name="street" not-null="false" />
<property name="number" not-null="false" />
<property name="zip" not-null="false" />
<property name="city" not-null="false" />
<property name="country" not-null="false" />
<property name="telephone" not-null="false" />
<property name="email" not-null="false" />
</class>
i found some guides which says using cascade operations, when i get
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:
but dont know which use, i know about cascade="all" but i dont know whether will be works in this case, i use this method to save/update:
public void ajaxNameListener(AjaxBehaviorEvent event) {
for(DealerListView diler : dealerList) {
if(diler.getDealerId() == getSelectedDealerId()) {
diler.setDealerId(selectedDealerId);
DealerData dilerko = new DealerData();
dilerko.setName(selectedDealerName);
Dealer dealer = BeanFactory
.getHotelDAOService(Dealer.class)
.findOne(selectedDealerId);
dealer.setActiveData(dilerko);
BeanFactory.getHotelDAOService(Dealer.class).update(dealer);// line 220 - in stacktrace is (at sk.bantip.hotel.web.controller.SalesController.ajaxNameListener(SalesController.java:220))
}
}
}
can somone give me a advice based on this situation? i think that some change must be made in these hbm.xml files,on some cascade operations but not sure about this which will be,Please left me here some post, I will be glad for any help Thank you and have a nice day.
Edit: and in child class DealerData i have a private properties, not sure about that but maybe will be need add this attribute access="field"
in DealerData.hbm.xml? because this allow Hibernate to read the value from the private variable instead of the public property.