I have 3 classes: Products, ProductsDescription and ProductsDescriptionPK.
Products has 1 ID: products_id ProductsDescription has 2 IDs: products_id and language_id which is in ProductsDescriptionPK, so ProductsDescription has EmbeddedId: ProductsDescriptionPK.
Since 1 product can have many descriptions in different languages, I wish to bind @OneToMany Products with ProductsDescription by using products_id, but I can't figure it out how to do it since ProductsDescription has composite key. Basically I wish to have Collection<ProductsDescription> in Products which are bindded with its ProductsDescription. Here are the following classes.
[ December 17, 2008: Message edited by: Alaneus Kingingestingest ] [ December 17, 2008: Message edited by: Alaneus Kingingestingest ]
The JPA specification doesn't specify a compound primary key with a entity, i don't know with Toplink but with Hibernate Entity Manager you use this
Another thing that i wanna suggest, you're overusing annotations. For instance you can use @Basic and @Column but it's not necessary. It's not necessary because @Column have an attribute nullable to add the not null constraint to the Column at hand. I think that the annotation configurer will do it's stuff faster with the least annotations as possible, if of course you can do it with less annotations,
I am relatively new to this but have been able to successfully accomplish what you're talking about with my own tables in the past couple of weeks.
In your products class you need something like this...
In your ProductsDescription class you need something like this...
Again, please keep in mind that this is new to me also. What I've done here seems to work, but I can't guarantee that it is 100% correct, is not missing something or does not include something extra. Therefore I hope that someone who has more knowledge can take a look and correct as necessary.