Hello,
we have an issue with the Hibernate Search index - regarding these three entities (root is only listed because it is the index root, but probably isn’t part of the problem).
@Indexed
@Entity
Root {
@IndexedEmbedded
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "root")
private Info info;
[...]
}
@Entity
@Table(name = "Info")
Info {
@IndexedEmbedded
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "Info_2_User_Data", joinColumns = {
@JoinColumn(name = "Info_ID", referencedColumnName = "Info_ID", columnDefinition = "INT(7)")},
inverseJoinColumns = {
@JoinColumn(name = "User_ID", referencedColumnName = "User_ID", columnDefinition = "INT(7)")})
private Set<User> userList = new HashSet<>();
@IndexedEmbedded
@ManyToOne
@JoinColumn(name = "Info_MainUser", referencedColumnName = "User_ID", columnDefinition = "INT(7)")
private User mainUser;
[...]
}
@Entity
@Table(name = "User_Data")
public class User {
@FullTextField(name = "user_name")
@Column(name = "User_Name", length = 20)
private String name;
@ManyToMany(mappedBy = "userList")
private Set<Info> infoForUserList = new HashSet<>();
@OneToMany(mappedBy = "mainUser")
private Set<Info> infoForMainUser = new HashSet<>();
[...]
}
As you can see there are two different relations between Info and User. If we change via our application the userList, everything is fine - new entries are added to the index. Buf if we do the same with the mainUser, the index is not updated. The DAO-Operation is in both cases the same - we edit Info and update the entity. In the database all changes are stored correctly.
My first assumption was that Hibernate has a problem because it gets confused with the two relations. So I removed the userList completely. But still no index updates for the mainUser. I also tried it without the infoForMainUser in User (we don’t need this bidirectional relation, it’s only for Hibernate Search/Lucene), but couldn’t make it work - it seems like I don’t understand extractions and how to configure it. But I don’t know if it really would fix the problem.
I’m not sure, if it is important, but these are the names of the indexes:
info.mainUser.user_name
info.userList.user_name
Do you have any idea, why the index isn’t updated for mainUser?
Thanks in advance and best regards.