-->
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: Updating collection destroys hibernate search index
PostPosted: Tue Nov 17, 2009 11:46 am 
Newbie

Joined: Tue Nov 17, 2009 10:35 am
Posts: 2
Hello,

I've got a bit of a weird issue, quite a serious one as far as my application goes!
I've got an object (lets call it a 'page') that contains a bunch of 'SharedItems' which represents users of the system that the page is shared to.

the mapping looks like this:

Code:
   <class name="Page" >
...
      <list name="sharedItems" cascade="all, delete-orphan" >
         <key column="page_id" />
         <index column="page_index"/>
         <one-to-many class="SharedItem" />
      </list>
...
   </class>


Code:
   <class name="SharedItem">
...
      <many-to-one    name="page"
                  column="page_id"
                  class="Page"
                  update="false"
                  insert="false" />
...
   </class>



And the annotations look like this:

in page class:
Code:
@Indexed
public class Page{
...
   @IndexedEmbedded(depth=2)
   private List<SharedItem> sharedItems = new ArrayList<SharedItem>();
...
}



in SharedItem class:
Code:
public class SharedItem{
...
   @ContainedIn
   private Page page;
...
}


regarding the (depth=2), the SharedItem contains 2 more collections but I don't believe they are the cause of the problem...

The way I update this collection in my 'page' class is to remove everything from the list and then put in all brand new objects (some of which are almost identical to the ones I removed but they are NEW objects with no ID's etc. so this should not matter.)
The code that does it looks like this:

Code:
//First remove all existing items.
page.getSharedItems().removeAll(
   page.getSharedItems()
);

//add in new sharedItems list that was passed into the method
Iterator<SharedItem> iterNewItems = newSharedItems.iterator();
while(iterNewItems.hasNext()){
   page.getSharedItems().add(iterNewItems.next());
}
         
DAO.savePage(page);



After this action completes, my search indexes seem to go crazy and all my indexes are gone. The files are still there but none of my hibernate search queries ever get any results.

If I manually run my initialise method which cycles through all indexed objects and indexes them, then everything is indexed fine again, but hibernate doesn't seem capable of handling this collection update about 90% of the time without me having to manually initialise everything straight after. Any ideas why this might be? Anything I'm doing wrong?

Thank you!
James.


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.