-->
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: Hibernate search - ClassBridge and entity update
PostPosted: Fri Aug 01, 2008 1:00 pm 
Newbie

Joined: Fri Oct 28, 2005 4:30 am
Posts: 16
Hi,

I have an entity Protein that has a Many-to-Many associations with entities Disease.
I implemented a ClassBridge that go through theses associations and add a field isLinkedToDisease to my index which will be equals to true or false if there is associations or not between my Protein and some diseases.

My Example :

My Protein is not linked to any Disease (isLinkedToDisease = false) when I first index my DB.
Then I add a Disease to my Protein via UI.
And then, when I look at the index (using Luke) the field isLinkedToDisease still equals to false.

I thought that the isLinkedToDisease would be updated, which would mean that a ClassBridge is called each time my Protein index is updated.

I tried to figure out when the ClassBridge is called and obviously the ClassBridge is called only during first indexing.

So my question is

Is a ClassBridge called only when I first index my entity ? or should the ClassBridge also be called when my entity is updated, in such a case, is a place to configure this ?

Or according to what I described above, is the ClassBridge the correct solution to store this kind of info ?

Thanks a lot

Nelly


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 06, 2008 8:30 am 
Hibernate Team
Hibernate Team

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

the ClassBridge is not only called at initial indexing, but also when the entity updates, however due to a bug in Hibernate Core collection changes would not trigger a update event. See http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-56. This got fixed in release 3.0.1.GA. The question is - which version of Search are you using?

Regarding the ClassBridge approach. I reckon a FieldBridge would do as well, provided you annotate the getters. You could add a property
hasDesease and a matching getter. Mark the getter as @Transient and place a @Field on it. In the getter you just return !deseaseList.isEmpty(). I think that should work.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 9:25 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
To correct some of the statelements of Hardy.
If you use @IndexedEmbedded and /@Contained in, Hibernate Search does care of updatig the index when an associated entity is changed. If you use a class bridge or a field bridge for that matter to walk through your associations, then Hibernate Search does not know that the association is involved: updating an associated entity will not trigger a reindexing.

You can always force the index manually by using session.index().

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 12:57 pm 
Newbie

Joined: Fri Oct 28, 2005 4:30 am
Posts: 16
Thanks a lot for your help !

I tried both solutions but still don't have the info I need in my index.

I've made a very simple test to see whether set update is propagated to my index and this is OK. If I add a new disease I will see its id in my index.

But in my case, having disease ids in my index does not fit with my needs.

I need to set isLinkedToDisease to true only if the protein has "valid" diseases (status != 'dropped' and publish_version > 0)

So my field isLinkedToDisease is "conditionnal".

I first tried to add a @Field on isLinkedToDisease getter (where I parse disease set to see if there is valid diseases).
I even tried to have this property mapped in my Protein mapping and based on a formula (to replace explicit parsing in my getter). Does not work ! :(

Then I tried to add @IndexEmbedded on my disease set + keep my isLinkedToDisease property with its @Field annotation. Does not work ! :(

Any other idea to manage the update of my isLinkedToDisease property ?


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.