I need to manually update the index but run into some trouble when updating @IndexedEmbedded objects.

In my domain I have Relations which can have multiple Addresses. The OneToMany relation from Relation to Address is annotated with @IndexedEmbedded and the ManyToOne from Address to Relation annotated with @ContainedIn.

Once an Address is updated (postal code changes to 'YY1234') I update the index by:

However I'm not able to find the updated relation when searching for 'YY1234' (I'm searching for the Relation, not the Address)

This all does work when I update the complete corresponding Relation instead of only the Address.

My questions:

- Am I doing something wrong?- If not, isn't HSearch supposed to figure this out itself (because of the @ContainedIn annotation).- Will HSearch 4 handle this in an easier way?

I found that writing some code to figure out which 'parent' object should be updated to avoid the problem isn't a trivial task and in many cases just plain impossible. You can't just go 'up' following all @ContainedIn marked relationships recursively and hope that this will bring you to the (possible multiple) parent domain classes. In many (more complex) domain models you will find yourself walking in never ending rounds.

could you provide you annotated classes? Who is the owner of the relationship? Are you sure that the relationship gets properly updated when you just change the address? Normally you have to edit both ends of a bidirectional relationship.

@Indexed@Entitypublic class Relation implements Serializable { // I should have called this Person instead of Relation to avoid confusion with the word relationship @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int relationsID;

Things work properly if I update the complete relation object like the code below. But I would like to avoid this step. Figuring out which object to load to update the index can be very hard in a more complex domain model.

Would be great if a member of the hibernate team can shed some light on this.

Edit: 21 okt 2011For anyone interested in this thread: I reported this as a bug/feature request HSEARCH-939 on Jira.I'm still not sure if it is a bug or just me trying to do something in the wrong way.