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
|