Code:
<class name="x" table="x">
<id name="ID" type="long" column="ID">
<generator class="increment"/>
</id>
<property name="Status">
<column name="STATUS"/>
</property>
<property name="lastName">
<column name="lastname"/>
</property>
<property name="firstName">
<column name="firstname"/>
</property>
<bag name="updates" cascade="all-delete-orphan">
<key column="ID" not-null="true"/>
<one-to-many class="x.Update"/>
</bag>
</property>
</class>
and this is how i saved it
Code:
x.setFirstName("xxx");
x.setLastName("xxx");
x.setStatus(1);
updated.setUpdated(df.format(today));
updated.setUpdatedBy("xxx");
List <Update> updates = new ArrayList();
updates.add(updated);
x.setUpdates(updates);
Session session = null;
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(x);
transaction.commit();
} catch (Exception e) {
if (transaction != null) {
transaction.rollback();
}
} finally {
session.close();
}
and now i wan to add another update to that record
thank You