Migrate Lucene annotations 3.2.1GA to Hibernate Search 3.0.0.Beta1: object removal
Changes in Hibernate Search are quite frequent, as it is in continued development. Today I found myself looking into a problem generated by migration from Hibernate-Lucene integration in 3.2.1.GA to the new Hibernate Search 3.0.0.Beta1.
The problem: deletion of an object in Hibernate will not trigger the removal from the Lucene index.
First, check the event listener: using a custom implementation I can see the onPostDelete method is called correctly. Still, no deletion from index and no error message either. Looking in the Hibernate Search sources I can see that the deletion uses the DocumentId marker in order to identify the field used for deletion. The old @Keyword(id=true) is deprecated and seems it no longer works.
The solution: Change the annotation from @Keyword(id=true) to @DocumentId. This will help Hibernate search do its magic.