-->
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.  [ 3 posts ] 
Author Message
 Post subject: Search - Indexing entities with scroll
PostPosted: Sat May 25, 2013 3:23 pm 
Newbie

Joined: Tue Nov 13, 2012 10:19 am
Posts: 5
Hello,

I'm trying to index an entity but it doesn't load an embedded collection.

Code:

Criteria criteria = fullTextSession.createCriteria(PollTO.class);
      criteria.createAlias("options", "options" JoinType.LEFT_OUTER_JOIN);
      criteria.createAlias("creationUser", "creationUser", JoinType.INNER_JOIN);

      ScrollableResults results = criteria.setFetchSize(batchSize).scroll(ScrollMode.FORWARD_ONLY);

      int index = 0;
      while (results.next()) {
         index++;
         fullTextSession.index(results.get(0)); // index each element
         if (index % batchSize == 0) {
            fullTextSession.flushToIndexes(); // apply changes to indexes
            fullTextSession.clear(); // clear since the queue is processed
         }
      }



Code:
@Entity
@Table(name = "poll", catalog = "poll")
@Indexed
public class PollTO implements Serializable {

       @Cascade({ CascadeType.SAVE_UPDATE })
   @OneToMany(fetch = FetchType.LAZY, mappedBy = "poll", orphanRemoval = true)
   @IndexedEmbedded
   public Collection<OptionTO> getOptions() {
      return options;
   }



Code:
@Entity
@Table(name = "option", catalog = "poll")
public class OptionTO implements Serializable, Comparable<OptionTO>

        @Column(name = "name", length = 50, nullable = false)
   @Field(analyze = Analyze.YES, store = Store.NO)
   public String getName() {
      return name;
   }




I have checked storing the property name of Option (@Field(analyze = Analyze.NO, store = Store.YES)) and it only saves the last option. I think the problem is in ".scroll(ScrollMode.FORWARD_ONLY)".

Do you have any idea of what happens? Thank you!


Top
 Profile  
 
 Post subject: Re: Search - Indexing entities with scroll
PostPosted: Sun May 26, 2013 8:11 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, which version are you using?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Search - Indexing entities with scroll
PostPosted: Sun May 26, 2013 1:25 pm 
Newbie

Joined: Tue Nov 13, 2012 10:19 am
Posts: 5
Hello,

Hibernate Search 4.1.1
Hibernate Core 4.1.4


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.