I have these ER relations:
Person
ID_PERSON NAMEAnimal
ID_ANIMAL NAMEPerson_animal
ID_PERSON ID_ANIMAL DATE_OF_BUYHow 开发者_如何转开发to map the property DATE_OF_BUY in the association?
The best way is normally to map the join table to a relationship class. i.e.
Person - OneToMany - AnimalOwnership - ManyToOne - Animal
See,
http://en.wikibooks.org/wiki/Java_Persistence/ManyToMany#Mapping_a_Join_Table_with_Additional_Columns
In JPA 2.0 you can also use a MapKey for some additional data, but this is normally more complex.
精彩评论