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!