Hello,
Would appreciate any inputs on this.
I have 3 entity tables
A
a_id
name
B
b_id
name
U
u_id
name
and I jhave the foll association table
A-B association: many to many
A_B_MAP
a_b_id (pk)
a_id (fk)
b_id(fk)
some of you may be goin 'whoa' over here because of the completely unnecessary primary key. But this is not my call. DBA's insist on having a single column PK for every table.
and we have
U-A-B-MAP association table
U_ABMAP_MAP
u_abmap_id (pk)
u_id (fk)
a_b_id (fk)
U has a many to many association with a table that is a join table between A and B.
I have objects for all 3 entities ofcourse. And I also have an object for A_B_MAP to effect the U-A_B_MAP association.
A and B have a ManyToMany association, using A_B_MAP as the join table, with A being the owner (the direction itself is immaterial - problem occurs in all cases).
U has a collection of A_B_MAP and does a many to many on it using U_ABMAP_MAP as the join table.
the JPA Mappings are textbook. I can post these if you indeed think this is a mapping issue i.e incorrect annotations.
When I try to run my test I get:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/edmunds/identity/identity-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Foreign key (FKFB06A81645B9499C:U_ABMAP_MAP [A_B_ID])) must have same number of columns as the referenced primary key (A_B_MAP [A_ID,B_ID])
Why is hibernate trying to enforce this? It seems that it expects A_B_MAP to have a composite primary key inspite of the fact that the A_B_MAP object has an @Id annotation on a_b_id only.
I tried using this with toplink and it does not seem to have a problem with it.
thanks
Pratik
|