-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: how to make automatic version check work in CMT/SLSB
PostPosted: Fri Oct 06, 2006 5:32 am 
Newbie

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
}
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.