-->
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.  [ 2 posts ] 
Author Message
 Post subject: update of the index for HIBERNATE SEARCH
PostPosted: Thu Jan 01, 2009 8:40 am 
Beginner
Beginner

Joined: Tue Feb 12, 2008 3:53 pm
Posts: 38
Hi,
I am using hibernate search and I indexed a class Event with a getter for "protocolStatus" indexed but which is not mapped in the database :

Code:
@Indexed
public class Event {
         .......
         .......   
        @Field(index=Index.UN_TOKENIZED)
   public int getProtocolStatus() {
      int result = -1;
      if(eventSequences.iterator().hasNext()){
         EventSequence eventSequence = (EventSequence)this.getEventSequences().iterator().next();
         result = eventSequence.getProtocol().getCalculatedStatus();
      }
      return result;
   }
        ......
        ......
}


I have the following problem : the value of "protocolStatus" in the index seems to be initialized at the creation of the object Event (value 0), but afterwards the value in the index is not updated. In my application, before I make a search of the objects events I get from the database all the objects events and I even update them one by one :

Code:
List<Event> events = eventDao.findByAll();
         
for (Event event : events) {
   eventDao.update(event);
}

I checked that I have 3 different values for "protocolStatus" : 0, 2 and 6. But the values stored in the index are not updated : the only value that I have in the index is 0. I don't understand why the index is not updated because from what I have read the index is updated when we use the sessionFactory of Hibernate and it is the case when I perform "List<Event> events = eventDao.findByAll();" or "eventDao.update(event);"
The reason is perhaps that "protocolStatus" is not mapped in the database. I don't know. Can anybody help me to resolve that problem ? Thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2009 9:30 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

it would have been great if you have posted the class with all annotations. For example, I assume that getProtocolStatus is mapped as transient, right?
Also, how is EventSequence mapped?

In your example getProtocolStatus is a calculated value which is based on EventSequence. The index for an Event will only be updated when you make a change to the entity. Calling eventDao.update(event) won't really help. You have to ensure that Event gets reindexed whenever EventSequence is getting updated. Normally this works via @IndexedEmbedded and @ContainedIn. But it really depends on how your entities are mapped.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.