-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: beginners question
PostPosted: Mon Jun 21, 2010 7:04 am 
Newbie

Joined: Fri Jun 18, 2010 5:15 pm
Posts: 3
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.