Thank you for replying. I thought flush is only to move the changes to the persistence Context. The reason I am creating new transaction is because the generated code from hbm2java produces this:
Code:
public void attachDirty(Account instance) {
log.debug("attaching dirty Account instance");
try {
HibernateUtil.currentSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Account instance) {
log.debug("attaching clean Account instance");
try {
HibernateUtil.currentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(Account persistentInstance) {
log.debug("deleting Account instance");
try {
HibernateUtil.currentSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Account merge(Account detachedInstance) {
log.debug("merging Account instance");
try {
Account result = (Account) HibernateUtil.currentSession().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
This is the code from the DAO. I couldn't find any tutorial about using it from the business layer. So I added synchWithDb() method, so that I can commit the changes to the DB. I tried flush but no changes on the DB side.