Hello,
can anyone help me to understand why the following does not work?
Document doc = DocumentDAO.createDocument();
DocumentLine line2 = new DocumentLineImpl();
line2.setProduct("my product name");
line2.setPrice(new BigDecimal(13));
line2.setQuantity(3);
doc.documentLine.add(line2);
doc.documentLine.remove(line2); //<-- soon after add, I use smart association
DocumentDAO.save(doc);
I expected to get a document with zero lines, but I have the following exception:
org.orm.PersistentException: org.hibernate.PropertyValueException: not-null property references a null or transient value: model.db.documents.documentlines.impl.DocumentLineImpl.document
Why? The DocumentLine has been removed from the collection, so why is hibernate trying to save it anyway?
Thank you!