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.