Hello
Please help me to understand what is wrong in my code.
I can not see info from embedded index, also field is not created in master index.
thanks a lot
Code:
@Entity
@Indexed(index="Usr")
public class Usr{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@DocumentId
public long getId() {
return id;
}
@Field(name="username", index=org.hibernate.search.annotations.Index.UN_TOKENIZED, store=Store.YES)
public java.lang.String getUsername() {
return username;
}
@OneToMany(mappedBy = "usr", fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@IndexedEmbedded(depth = 1)
public Set<UserProfileData> getUserProfileData() {
return userProfileData;
}
public void setUserProfileData(Set<UserProfileData> userProfileData) {
this.userProfileData = userProfileData;
}
}
@Entity
@Indexed(index="UserProfileData")
public class UserProfileData implements Serializable {
@Id
@DocumentId
public long getId() {
return id;
}
@Field(index=org.hibernate.search.annotations.Index.TOKENIZED, store=Store.YES)
public java.lang.String getValue() {
return value;
}
@ManyToOne
@ContainedIn
public com.joyplay.shared.ejb.persistence.Usr getUsr() {
return usr;
}
public void setUsr(com.joyplay.shared.ejb.persistence.Usr usr) {
this.usr = usr;
}
}
Manual indexing don't work for master index document
Code:
public void setUserProfileData(long usrID,UserProfileData.Data key,String value,
UserProfileData.Permission permission){
Usr u = em.find(Usr.class, usrID);
UserProfileData data = new UserProfileData();
data.setUsr(u);
...
em.persist(data);
try {
FullTextEntityManager fullTextEntityManager =
org.hibernate.search.jpa.Search.createFullTextEntityManager(em);
fullTextEntityManager.index(data);
fullTextEntityManager.index(u);
}catch(Exception e){
e.printStackTrace();
}
}