-->
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.  [ 4 posts ] 
Author Message
 Post subject: @IndexedEmbedded referenced by a class that is also Embedded
PostPosted: Fri Oct 15, 2010 6:25 pm 
Beginner
Beginner

Joined: Wed Nov 21, 2007 10:24 am
Posts: 25
I have a class that is @IndexedEmbedded in another class which is referenced by another class which has that class @IndexedEmbedded. It goes as follows: Document => Person => Email. Document => Person is a OneToOne, but Person => Email is a ManyToMany. I'm getting a LazyInitializationException when it tries to go down in to Email I believe. At first I thought it was a consequence of using Spring for an @Transactional method, but even when I create the EntityManager manually, it still has that problem. Can you not have @IndexedEmbedded things that deep? How can I get rid of this issue since I still want Person to be embedded in Document to make it searchable for Documents related to that person, but I also want to be able to search Email in Person.


Top
 Profile  
 
 Post subject: Re: @IndexedEmbedded referenced by a class that is also Embedded
PostPosted: Mon Oct 18, 2010 6:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
There should no issue with nested @IndexedEmbedded configurations. The important thing to remember is that the session/transaction which loaded the initial entity has to be open during the indexing process (during indexing the lazy loaded properties have to be fetched!). In a web framework you often achieve this via the open session in view pattern.

It it hard to provide more help without seeing your actual annotated classes and how you index them (the code between opening and closing of the session). However, this topic has been discussed many times on this forum. Just search for LazyInitializationException and you should get some more pointers. In most cases the problem is wrong session handling or wrong transaction demarcation.

--Hardy


Top
 Profile  
 
 Post subject: Re: @IndexedEmbedded referenced by a class that is also Embedded
PostPosted: Mon Oct 18, 2010 9:15 am 
Beginner
Beginner

Joined: Wed Nov 21, 2007 10:24 am
Posts: 25
hardy.ferentschik wrote:
There should no issue with nested @IndexedEmbedded configurations. The important thing to remember is that the session/transaction which loaded the initial entity has to be open during the indexing process (during indexing the lazy loaded properties have to be fetched!). In a web framework you often achieve this via the open session in view pattern.

It it hard to provide more help without seeing your actual annotated classes and how you index them (the code between opening and closing of the session). However, this topic has been discussed many times on this forum. Just search for LazyInitializationException and you should get some more pointers. In most cases the problem is wrong session handling or wrong transaction demarcation.

--Hardy


I haven't tried it with individually indexing entities, but I'm getting it when I try to use the MassIndexer. And I do have the open session in view filter going, so that's not the problem. I'll probably try fetching them all manually and indexing them, but at the moment the problem is with MassIndexer.


Top
 Profile  
 
 Post subject: Re: @IndexedEmbedded referenced by a class that is also Embedded
PostPosted: Mon Oct 18, 2010 9:22 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
To debug this further you would need to post your annotated entities, the full exception stacktrace, and the code you use for indexing. Even better would be a testcase which shows the issue.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

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.