Hibernate version:2.1.6
Mapping documents: <many-to-one name="productFamily" class="com.uss.cm4wless.domain.ProductFamily" not-null="true" > <column name="family_ID" /> </many-to-one>
<set name="products" lazy="true" inverse="true" > <key> <column name="family_ID" /> </key> <one-to-many class="com.uss.cm4wless.domain.Product" /> </set>
Code between sessionFactory.openSession() and session.close(): tx = session.beginTransaction(); Product product = (Product) session.load(Product.class, productId); ProductFamily family = product.getProductFamily(); Set products = family.getProducts(); products.remove(product); session.delete(product);
session.flush(); tx.commit();
Full stack trace of any exception that occurs: no
Name and version of the database you are using: mysql 3.23.58
The generated SQL (show_sql=true): Hibernate: delete from cm4wless_mobile_product where product_ID=?
Debug level Hibernate log excerpt:
everything is OK if collection contain more than one child. problem is occured when only one child is left in collection. the last child is deleted in
database, but it still show in collection later.
|