Hi
I have 3 entities(EntityA,EntityB,EntityC).
EntitiyA has a composite primary key (id,version,instance) EntitiyC has a composite primary key (id,version,instance)
EntitiyB has a composite primary key of the other two entities (EntitiyA .id,EntitiyA .version,EntitiyC.id ,EntitiyC .version,EntityB.version);
So entityB has composite primary key pointing to 2 entities.Also it has its own column (EntityB.version) as part of the same composite primary key.
I tried like this on entityA: @OneToMany(mappedBy = "entityA", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private List<EntitiyA > entityList = new ArrayList<EntitiyA >();
On EntityB: It is manytoOne relationship from EntityB to EntityA @ManyToOne @JoinColumns({ @JoinColumn(name="id", referencedColumnName ="id", insertable=false, updatable=false), @JoinColumn(name="version", referencedColumnName ="version", insertable=false, updatable=false) }) private EntitiyA entityA;
It is a onetoone relationship from entityB to entityC @OneToOne(fetch=FetchType.EAGER) @JoinColumns({ @JoinColumn(name="id", referencedColumnName="id", insertable=false, updatable=false), @JoinColumn(name="version", insertable=false, referencedColumnName="version", updatable=false) })
But it give me mapping error.It asks me that all primary key should be part of foreign key.
Please help.
|