-->
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.  [ 5 posts ] 
Author Message
 Post subject: Using @OneToMany along with @IndexedEmbedded throw Exception
PostPosted: Thu Dec 16, 2010 10:19 am 
Newbie

Joined: Thu Dec 16, 2010 9:39 am
Posts: 3
Hi All,

I've searched the forum and have come across a few similar posts - they are all close but none of those talk exactly about the issue that I’m having so I figure I should start a new thread.

The issue I'm having is that when I use EAGER loading the indexing works fine but as soon as I change the fetch type to LAZY, which is what I actually want to do, it blows up while creating hibernate indexes.

I have made sure that the method that creates search indexes has an @Transactional annotation on it. I have spent a lot of time looking through different posts and have tried a many different things but it in vain. Any help is much appreciated!!

Code:
  @OneToMany(fetch = FetchType.LAZY)
  @JoinTable(
      name="AssetAddressHistory",
      joinColumns=
        @JoinColumn(name="uniqueAssetId", referencedColumnName="uniqueAssetId", insertable=false, updatable=false),
      inverseJoinColumns=
        @JoinColumn(name="addressSequenceNumber", referencedColumnName="addressSequenceNumber", insertable=false, updatable=false))
  @WhereJoinTable(clause = "currentAssetLocation = 'Y'")
  @NotFound(action=NotFoundAction.IGNORE)
  @IndexedEmbedded
  protected List<AssetAddress> assetAddress; 


Exception:
Code:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: [package_name].assetAddress, no session or session was closed
   at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
   at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
   at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
   at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
   at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:436)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:380)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:328)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:317)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.addWorkToBuilderQueue(BatchedQueueingProcessor.java:153)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.processWorkByLayer(BatchedQueueingProcessor.java:140)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:128)
   at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.flushWorks(PostTransactionWorkQueueSynchronization.java:69)
   at org.hibernate.search.backend.impl.TransactionalWorker.flushWorks(TransactionalWorker.java:78)
   at org.hibernate.search.impl.FullTextSessionImpl.flushToIndexes(FullTextSessionImpl.java:98)
        ...


Regards
Abrar


Top
 Profile  
 
 Post subject: Re: Using @OneToMany along with @IndexedEmbedded throw Exception
PostPosted: Thu Dec 16, 2010 3:18 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello Abrar,
could you please try out version 3.3.0.Final; I wasn't aware of issues in this area regarding LazyInitializationException, though for performance reasons we basically rewrote the code related to this operation which is failing for you, so it might have solved this, or not.
Which version are you using?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Using @OneToMany along with @IndexedEmbedded throw Exception
PostPosted: Thu Dec 16, 2010 3:57 pm 
Newbie

Joined: Thu Dec 16, 2010 9:39 am
Posts: 3
Hi Sanne,

Thanks for replying! I tried 3.2 yesterday which gave me the same results.

I'm in a middle of some code refactoring so can't try 3.3 at the moment but I'll try it Monday morning and will get back to you as soon as I can.

Regards
Abrar


Top
 Profile  
 
 Post subject: Re: Using @OneToMany along with @IndexedEmbedded throw Exception
PostPosted: Tue Dec 21, 2010 11:24 am 
Newbie

Joined: Thu Dec 16, 2010 9:39 am
Posts: 3
Hi Sanne,

Apologies for the late response. I tried using version 3.3 but getting the same exact exception. Any ideas?

Any help would be much appreciated!

Regards
Abrar


Top
 Profile  
 
 Post subject: Re: Using @OneToMany along with @IndexedEmbedded throw Exception
PostPosted: Tue Dec 21, 2010 11:43 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
could you check that you're committing the transactions before closing the Session?
If that doesn't work, I'll need a unit test with your model, of course the minimal part of it which is able to showcase the issue, and please attach it to a JIRA issue.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.