I have a class Listing with two collections reviews and discussions. Both Review and Discussion are subclasses mapped to the same table, distinguished by a discriminator column type. I am using Seam 1.2.1 but the problem is most likely related to the persistence mapping. Here are the mappings:
@Entity @Name("listing") public class Listing implements java.io.Serializable { ... @OneToMany(targetEntity = Review.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "listing") private Set<Review> reviews = new HashSet<Review>(0); @OneToMany(targetEntity = Discussion.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "listing") private Set<Discussion> discussions = new HashSet<Discussion>(0); }
@Entity @Name("review") @DiscriminatorValue("review") @Indexed(index="review") public class Review extends com.n2.bo.UserContent implements java.io.Serializable { ... @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "listingId") private Listing listing; } @Entity @Name("discussion") @DiscriminatorValue("discussion") @Indexed(index="discussion") public class Discussion extends com.n2.bo.UserContent implements java.io.Serializable { ... @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "listingId") private Listing listing; } @Entity @Table(name = "user_content") @Name("userContent") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) public class UserContent implements java.io.Serializable { ... }