Hi,
How are you supposed to map an includePaths relation to an object that has a combined primary key?
Code:
@Entity
@AssociationOverrides({
@AssociationOverride(name = "pk.user",
joinColumns = @JoinColumn(name = "FK_userId")),
@AssociationOverride(name = "pk.group",
joinColumns = @JoinColumn(name = "FK_groupId"))
})
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE,region=CacheRegion.GROUP)
public class GroupMember{
@EmbeddedId
public GroupMemberId getPk() {
return pk;
}
}
@Embeddable
public class GroupMemberId implements Serializable{
public GroupMemberId(){}
public GroupMemberId(Usor user, Group wallGroup){
this.user=user;
this.group = wallGroup;
}
@ManyToOne(optional=false)
@ContainedIn
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@ManyToOne(optional=false)
public Group getGroup() {
return group;
}
}
@Entity
@Indexed
public class User{
@OneToMany(cascade=CascadeType.ALL,orphanRemoval=false,fetch=FetchType.LAZY, mappedBy="pk.user")
@IndexedEmbedded(prefix="member.",includePaths={"pk.group.id","blocked","active"})
public List<GroupMember> getGroupMemberships() {
return groupMemberships;
}
}
I would expect that Hibernate Search would accept "pk.group.id" as a path on getGroupMemberships. But it doesn't.
I also tried adding @EmbeddedId to getPk().
My workaround so far was adding a @Transient @IndexedEmbedded getGroup() member to GroupMember, but apart from it being somewhat ugly, I also run into Lazy Exception errors in some situations on IndexedEmbedded relations within the Group.
Is there a definitive answer on how to map Embedded Primary keys when used with Hibernate Search?