I have an issue when trying to load a one-to-many relationship when a List of objects are returned.
I'm using a join table named article_image between my article table and the image table.
tables:
article(article_id)
image(image_id)
article_image(article_id, image_id)
Code:
@Component
@Entity
@Indexed
@Table(name="article")
@FullTextFilterDef(name="notActive", impl=ActiveArticleFilterFactory.class)
public class Article implements java.io.Serializable {
@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
@JoinTable(name = "article_image",
joinColumns = {
@JoinColumn(name="article_id", unique = true)
},
inverseJoinColumns = {
@JoinColumn(name="image_id")
}
)
private Set<Image> articleImages = new HashSet<Image>(0);
If I do a findByID() on Article where only the single instance is returned the articleImages Set is populated. But if I do a findByProperty() or anything else where a list of Article is returned articleImages is always empty.
Any thoughts? Do you need to see anything else?