"as generated by Hibernate Tools"; does this mean reveng?
I use reveng to generate my java code, and the class with the collection is annotated:
Code:
class Invoice ...
@OneToMany(fetch=FetchType.LAZY, mappedBy="invoice")
public Set<LineItem> getLineItems() {
return this.lineItems;
}
And the items are:
Code:
class LineItem ...
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="InvoiceId", nullable=false)
public Job getInvoice() {
return this.invoice;
}
In my [limited] experience, if you add LineItems to the invoice.getLineItems() Set, and then update(invoice) the right thing happens.
Assuming the LineItem you add is correctly created with reference back to the Invoice.