-->
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: Session-per-conversation with HB really the holy grail?
PostPosted: Sun May 31, 2009 5:23 am 
Newbie

Joined: Wed Feb 04, 2009 7:27 am
Posts: 3
Hi, experts.
After reading and testing a little bit the Session-per-conversation-pattern using Hibernate's FlushMode.MANUAL (as described in "JPA with HB")
i'm quite disappointed about it.

Since nothing is flushed to the database until the final manual flush, its impossible to use queries to find new or changed entites from the current conversation!
With the default flush-mode AUTO the Session is flushed before the first query, resulting in proper finding the non-commited, but temporarly inserted entities.

Code:
//transaction.begin

Person p =  new Person();
p.setName("test");
em.persist(p);

em.createQuery("from Person where name=:name").setParameter(name,"test");

//transaction.end


Since everybody loves the session-per-conversation pattern, i guess i must be wrong :-(
Maybe its an antipattern to query objects which are modified or newly created within the same "conversation"?!

Any comments?
Jens

PS: It seems that only the antipattern "long running transaction" allows such code and spans also users think-time.


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.