-->
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: Hibernate JPA 1.0 join fetch not work without JTA Tx
PostPosted: Tue Oct 26, 2010 12:36 pm 
Newbie

Joined: Tue Oct 26, 2010 11:53 am
Posts: 4
Hi,

I've been using Hibernate JPA 1.0 which comes with 3.4 GA. In the persistence.xml, I configured JTA as transaction type. I use named query and join fetch. It works well when my SLSB starts a Tx (e.g. set transaction attribute to REQUIRED), and then calls Hibernate persistence function.

However, when no Tx is started (e.g. set transaction attribute to NOT_SUPPORTED), I got org.hibernate.LazyInitializationException because the associated objects are not populated in the POJO loaded.

According to JPA spec, a join fetch should retrieve details of objects on the right hand side. Since showsql is on, the initial sql Hibernate executed IS correct with all fields retrieved. It seems, however, Hibernate didn't use the fetched info to create relational fields of the main POJO but rather still used proxy. When Tx is on, I can see additional queries being fired when relational fields are accessed.

Is this correct according to spec? How should I get a POJO with relational fields filled out when there's NO Tx?

Thanks,
- John


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.