We're using seperate insert method and an update methods, i.e.:
public final BasePk save(final BaseVO vo) {
try {
final Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(vo);
// return the VO pk object
tx.commit();
HibernateUtil.closeSession();
return vo.createPk();
} catch (final Exception ex) {
System.out.println(ex);
throw new DAOException(ex.getMessage());
}
}
and
public final void update(final BasePk pk, final BaseVO vo) {
BaseVO baseVO = findByPrimaryKey(pk);
save(vo);
}
This should get over the null problem as you are doing the find in the update before save is called.
VO dirty flags are used to indicate if a VO property has been modified, take a look at:
http://authors.phptr.com/corej2eepatter ... ap8_2.html
It might come in handy for you.