I am new to EJB and JPA and I need your help please.
Suppose that we have two Entities A (mapped to DB table A with Pk field named id) and B (mapped to a DB table B with FK a_id that references A.id in a many to one relationship)
in entity class A I have:
in entity class B I have:
Based on my understanding that should work but Eclipse is giving me referenced column "id" in join column"a_id" cannot be resolved. I checked eclipse's manual and it says that i need to make sure that the column exists in DB and it does, so why am I getting that error?
I think your topic says it all. I think you need an @JoinedColumn tag above the Collection. When I just have @ManyToOne and I let the tables be automatically created, then what happens if you have the parent and child tables, but it also creates a join table. When I add @JoinedColumn, it just creates parent and child tables where the child table gets a foreign key reference.
I don't think the @GeneratedValue annotation works on String attributes/fields. Also, you don't need to specify the @Column annotation if the column name is identical to the class' attribute/field name.
Joined: Aug 06, 2007
Sergio thanks for the tips, I made the modifications and the problem is still there.
I noticed that this problem only happens with the USER table! The table is created and there is a column called id that acts as a PK.