-->
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: Totally strange org.hibernate.LazyInitializationException
PostPosted: Thu Mar 18, 2010 5:25 am 
Newbie

Joined: Mon May 11, 2009 11:16 am
Posts: 13
Hi Forum,

I'm getting an org.hibernate.LazyInitializationException but I don't know why.

I've a method within an Stateless Bean (EJB3.0) which is annotated with transaction attribute NOT_SUPPORTED. When I query the database
I'll get the correct instance, but when I call a method "entity.getSomeCollection" I'll will get the org.hibernate.LazyInitializationException. It's kind of strange because I used this mechanism in the same way a thousand times before.

Here some code
Code:
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public StructureNode someMethodName(....){
/* Code removed because it is unnecessary */
     actualAssociatedNode = (StructureNode) em.createQuery(GET_STRUCTURE_NODE_BY_INTERNAL_SEARCH_KEY).
                     setParameter("businessKey", ouSrcSystemBusinessKey.concat(ouStructureKey)).
                     getSingleResult();
     
      /************************************************
        NEXT LINE THROWS THE EXCEPTION
       ************************************************/
     actualAssociatedNode.getChildNodes();
/* Code removed because it is unnecessary */
}


The method is called by another public method within the same bean (also TransactionAttributeType.NOT_SUPPORTED), if you need to know. Within the calling method I do the same and this works!! Why it doesn't work here??? I'm stuck

Thx for suggestions

EDIT: Some further information: It works when I set the TransactionAttribute to REQUIRED or REQUIRES_NEW, but I don't want to open a transaction for reading access!! Does I have to?


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.