Hi,
I am using Hibernate 3.5 with JPA 2 and would like to persist 2 classes:
User & Product
All products are read-only and should never be written by any User,
instead every User may hold read-only-references to N Products:
Code:
class User {
@OneToMany
@MapKey(name = "id")
private Map<Integer, Product> products;
}
The user-product mapping is held in a mapping-table: user_products
Whenever I save the User objects via user.save() Hibernate tries to save the Products in the product table as well.
There must be some way to tell Hibernate only to save the user_id + product_id in the mapping-table: user_products.
Could anyone give me a hint on how to achieve this?
Thanks!