# Composition: Invoice -> InvoiceLine, cascade = ALL + orphanRemoval = true
# Hibernate ORM 8.0.0.CR1, H2, JDK 25

== persist(invoice) with two new lines, lines never persisted explicitly
-- persist(inv); flush()
   sql> insert into Invoice (number,id) values (?,default)
   sql> insert into InvoiceLine (description,invoice_id,id) values (?,?,default)
   sql> insert into InvoiceLine (description,invoice_id,id) values (?,?,default)
raw rows: invoice=1 InvoiceLine=2

== remove one line from the collection (the invoice stays)
-- lines.remove(0); flush()
   sql> select i1_0.id,i1_0.number from Invoice i1_0 where i1_0.id=?
   sql> select l1_0.invoice_id,l1_0.id,l1_0.description from InvoiceLine l1_0 where l1_0.invoice_id=?
   sql> delete from InvoiceLine where id=?
raw rows: invoice=1 InvoiceLine=1

== remove the invoice
-- remove(find(Invoice)); flush()
   sql> select i1_0.id,i1_0.number from Invoice i1_0 where i1_0.id=?
   sql> select l1_0.invoice_id,l1_0.id,l1_0.description from InvoiceLine l1_0 where l1_0.invoice_id=?
   sql> delete from InvoiceLine where id=?
   sql> delete from Invoice where id=?
raw rows: invoice=0 InvoiceLine=0
