Joined: Sun Sep 03, 2006 1:21 am Posts: 9
|
i use Hibernate with CMT.
i have a method on a stateless session bean which uses a DAO to retrieve an entity by id and updates it. The DAO uses sessionFactory.getCurrentSession(). Apparently, automatic version check doesnot work because the entity is not detached but reloaded in every session per thread. Is there a way to avoid manual version check and make automatic version check work in CMT?
StatelessSessionBean {
// note the dao uses the session returned by getCurrentSession().
void saveEntity(entityDTO) {
entity = dao.findEntity(id);
entity.setAttribute(entityDTO.getAttribute());
// how to get rid of this manual check?
if (entity.getVersion != entityDTO.getVersion()) {
throw VersionException;
} else {
dao.saveEntity(entity); // call session.saveOrUpdate
}
}
}
|
|