Not-null property references a null or transient value?

Every InvoiceItem must have a an Invoice attached to it because of the not-null="true" in the many-to-one mapping. So the basic idea is you need to set up that explicit relationship in code. There are many ways to do that.

On your class I see a setItems method. I do NOT see an addInvoiceItem method. When you set items, you need to loop thru the set and call item.

SetInvoice(this) on all of the items. If you implement an addItem method, you need to do the same thing. Or you need to otherwise set the Invoice of every InvoiceItem in the collection.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

Facing trouble in saving parent/child object with hibernate. Any idea would be highly appreciated. Org.hibernate.

PropertyValueException: not-null property references a null or transient value: example.forms.InvoiceItem. Invoice at org.hibernate.engine.Nullability. CheckNullability(Nullability.

Java:100) .... (truncated) hibernate mapping: InvoiceManager. Java class InvoiceManager { public Long save(Invoice theInvoice) throws RemoteException { Session session = HbmUtils. GetSessionFactory().

GetCurrentSession(); Transaction tx = null; Long id = null; try { tx = session. BeginTransaction(); session. Persist(theInvoice); tx.commit(); id = theInvoice.getId(); } catch (RuntimeException e) { if (tx!

= null) tx.rollback(); e.printStackTrace(); throw new RemoteException("Invoice could not be saved"); } finally { if (session.isOpen()) session.close(); } return id; } } Invoice. Java public class Invoice implements java.io. Serializable { private Long id; private Date invDate; private int customerId; private Set items; public Long getId() { return id; } public Date getInvDate() { return invDate; } public int getCustomerId() { return customerId; } public Set getItems() { return items; } void setId(Long id) { this.

Id = id; } void setInvDate(Date invDate) { this. InvDate = invDate; } void setCustomerId(int customerId) { this. CustomerId = customerId; } void setItems(Set items) { this.

Items = items; } } InvoiceItem. Java public class InvoiceItem implements java.io. Serializable { private Long itemId; private long productId; private String packname; private int quantity; private double price; private Invoice invoice; public Long getItemId() { return itemId; } public long getProductId() { return productId; } public String getPackname() { return packname; } public int getQuantity() { return quantity; } public double getPrice() { return price; } public Invoice getInvoice() { return invoice; } void setItemId(Long itemId) { this.

ItemId = itemId; } void setProductId(long productId) { this. ProductId = productId; } void setPackname(String packname) { this. Packname = packname; } void setQuantity(int quantity) { this.

Quantity = quantity; } void setPrice(double price) { this. Price = price; } void setInvoice(Invoice invoice) { this. Invoice = invoice; } } hibernate link|improve this question asked Jun 17 '11 at 17:41Leslie Norman838419 88% accept rate.

Leslie, to answer that I need to see where you are creating the objects and how you are associating them. – hvgotcodes Jun 17 '11 at 20:40.

For followers, this error message can also mean "you have it referencing a foreign object that hasn't been saved to the DB yet" (even though it's there, and is non null).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions