Possible reason 1: Collection of Basic type
If the collection (eg Set) is of basic data types (eg String) then you want a @ElementCollection(see reference).
Possible reason 2: target
I had two classes with bi-directional @ManyToMany relationship.They both return Sets i.e. Generics therefore I have to set
target. But I did the mistake to set it to Set but they right
was setting it to the types of the elements the Sets include.
@Entity @Table(name="A") public class A implements Serializable { //@ManyToMany(...,targetEntity=Set.class) //wrong @ManyToMany(...,targetEntity=A.class) //right public Set getManyB(){...} } @Entity @Table(name="B") public class B implements Serializable { @ManyToMany(...,targetEntity=Set.class) //wrong @ManyToMany(...,targetEntity=A.class) //right @JoinTable(...) public Set getManyA(){...} }
No comments:
Post a Comment