-->
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: One-to-Many non identifying is not working
PostPosted: Mon Nov 25, 2013 3:31 pm 
Newbie

Joined: Mon Nov 25, 2013 3:14 pm
Posts: 1
Hi there, everyone!
This is the problem, one-to-many non identifying relation is not working properly. I'm creating a Productfamily instance which contains a set of Products, the thing is that the Productfamily instance is created and the Products instances as well, but without dependence on each one.

Here are the mappings I have, for Productfamily:
Code:
<set name="products" inverse="true">
   <key>
   <column name="idproductfamily" />
   </key>
   <one-to-many class="classes.Product" />
</set>


and for Product:
Code:
<many-to-one name="familyproduct" class="classes.Familyproduct" update="false" insert="false" fetch="select">
   <column name="idproductfamily" />
</many-to-one>


And this is the method I have in order to save this whole thing into the database:

Code:
session.saveOrUpdate(famprod);
for (Product p : famprod.getProducts()) {
   ProductId id = new ProductId();
   id.setType(p.getNType().getIdType());
   id.setIdProduct(DAOProduct.getId());
   p.setId(id);
   p.setFamilyproduct(famprod);
   session.saveOrUpdate(p);
}
transaction.commit();


That's it. I'm using Postgres 9.0 and when I call the products set it came empty, but the products set exist... any idea, or recomendation?

Thanks in advance.


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.