-->
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.  [ 3 posts ] 
Author Message
 Post subject: Use non-id field as DocumentId
PostPosted: Tue Oct 04, 2016 8:09 pm 
Newbie

Joined: Mon Oct 03, 2016 8:08 pm
Posts: 4
It was originally posted in the Hibernate user channel, but really should be posted here.

Hi, I understand Hibernate Search uses @ID field as Document Id when using JPA. However, in our case, we have a surrogate id as primary key and a natural (business) ID as another field. Because the way our business works, the underlying DB data can be changes in two ways: incremental changes via Hibernate and a overall data replacement via SQL (bypassing Hibernate). No matter how the data is changed, the natural ID should always refer to the same entity in real world. but the surrogate ID will be changes since it is auto generated.

What I want to do is to tell Lucene to index the natural ID rather than the surrogate ID so that even though the underlying data is changed, the search result I got from using the old index is still valid.

Is there a way in Hibernate Search to use a field as DocumentId while having the @ID annotation on another field?


Top
 Profile  
 
 Post subject: Re: Use non-id field as DocumentId
PostPosted: Fri Oct 07, 2016 2:33 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
You can use @DocumentId for that purpose.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Use non-id field as DocumentId
PostPosted: Fri Oct 07, 2016 3:42 am 
Newbie

Joined: Mon Oct 03, 2016 8:08 pm
Posts: 4
Gunnar wrote:
You can use @DocumentId for that purpose.

--Gunnar


I might be wrong but I think @DocumentId and @ID should be on the same field? I tried to put @DocumentId on another field but got errors


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