-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @IndexedEmbedded on collections ...
PostPosted: Thu Apr 17, 2008 6:51 am 
Newbie

Joined: Tue Oct 10, 2006 2:38 pm
Posts: 17
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();
      }
   }



Top
 Profile  
 
 Post subject: my mistake
PostPosted: Thu Apr 17, 2008 11:01 am 
Newbie

Joined: Tue Oct 10, 2006 2:38 pm
Posts: 17
I changed fetch = FetchType.EAGER to LAZY and it's ok now


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.