epbernard wrote:
using cache ?
show the simplest code reproducing that.
no cahe used.
This is the code:
Code:
Configuration cfg = new Configuration();
sessionFactory = cfg.configure().buildSessionFactory();
Session sess = sessionFactory.openSession();
NetPortalCustomer user = null;
List result = null;
try {
Query q =
sess.createQuery(
"from necustomer in class com.db.device.NetPortalCustomer where necustomer.name = :name");
q.setString("name", "sherban");
result = q.list();
if (result.size() == 0)
throw new ObjNotFoundException();
user = (NetPortalCustomer) result.get(0);
} catch (HibernateException e) {
throw new DAOException(e);
} finally {
sess.close();
}
ContactInformation contactInfo = new ContactInformation();
contactInfo.setName("ci");
if (user.getContactInfo() != null) {
contactInfo.setId(user.getContactInfo().getId());
}
user.setContactInfo(contactInfo);
sess = sessionFactory.openSession();
try {
Transaction tx = sess.beginTransaction();
sess.update(user);
tx.commit();
} catch (HibernateException e) {
throw new DAOException(e);
} finally {
sess.close();
}
and the mappings:
<joined-subclass name="com.diatem.db.device.NetPortalCustomer" table="necustomer">
<key column="id"/>
<property name="mgmtUserName" column="mgmt_user_name" type="string"/>
<property name="mgmtPassword" column="mgmt_passwd" type="string"/>
<property name="mgmtAccess" column="mgmt_access" type="boolean"/>
<many-to-one name="contactInfo" class="com.diatem.db.device.ContactInformation" cascade="all"/>
<many-to-one name="locationInfo" class="com.diatem.db.device.LocationInformation" cascade="all"/>
<set name="srvContractInfoList" cascade="all-delete-orphan" inverse="true" lazy="false">
<key column="customer"/>
<one-to-many class="com.diatem.db.service.SrvContractInfo"/>
</set>
</joined-subclass>
and
<class name="com.diatem.db.device.ContactInformation" table="contactinfo" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false">
<id name="id" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="name" column="name" type="string" not-null="true" unique="false"/>
<property name="salutation" column="salutation" type="string"/>
<property name="phoneNumber" column="phone_number" type="string"/>
<property name="mobilePhone" column="mobile_phone" type="string"/>
<property name="pagerNumber" column="pager_number" type="string"/>
<property name="email" column="email" type="string" not-null="true"/>
</class>
please help ...
TIA,
--steve p.