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.