# Deleting a parent and its (non-cascaded) child in one flush, parent removed first
# Hibernate ORM 7.4.15.Final, H2, JDK 25

== ProjectGood.owner is nullable
-- default settings
-- remove(parent); remove(child); flush()
   sql> select au1_0.id,au1_0.name from AppUser au1_0 where au1_0.id=?
   sql> select pg1_0.id,pg1_0.owner_id,pg1_0.title from ProjectGood pg1_0 where pg1_0.id=?
   sql> update ProjectGood set owner_id=?,title=? where id=?
   sql> delete from AppUser where id=?
   sql> delete from ProjectGood where id=?
raw rows: parent=0 child=0
-- hibernate.flush.queue.type=legacy  (a setting Hibernate 8 introduced; ignored by 7.x)
-- remove(parent); remove(child); flush()
   sql> select au1_0.id,au1_0.name from AppUser au1_0 where au1_0.id=?
   sql> select pg1_0.id,pg1_0.owner_id,pg1_0.title from ProjectGood pg1_0 where pg1_0.id=?
   sql> update ProjectGood set owner_id=?,title=? where id=?
   sql> delete from AppUser where id=?
   sql> delete from ProjectGood where id=?
raw rows: parent=0 child=0

== Card.board is optional = false (the foreign key cannot be nulled)
-- default settings
-- remove(parent); remove(child); flush()
   sql> select b1_0.id,b1_0.name from Board b1_0 where b1_0.id=?
   sql> select c1_0.id,c1_0.board_id,b1_0.id,b1_0.name,c1_0.title from Card c1_0 join Board b1_0 on b1_0.id=c1_0.board_id where c1_0.id=?
   threw: org.hibernate.PropertyValueException
   cause: not-null property references a null or transient value for entity com.ankurm.cascade.Card.board
raw rows: parent=1 child=1
-- hibernate.flush.queue.type=legacy  (a setting Hibernate 8 introduced; ignored by 7.x)
-- remove(parent); remove(child); flush()
   sql> select b1_0.id,b1_0.name from Board b1_0 where b1_0.id=?
   sql> select c1_0.id,c1_0.board_id,b1_0.id,b1_0.name,c1_0.title from Card c1_0 join Board b1_0 on b1_0.id=c1_0.board_id where c1_0.id=?
   threw: org.hibernate.PropertyValueException
   cause: not-null property references a null or transient value for entity com.ankurm.cascade.Card.board
raw rows: parent=1 child=1

outcomes: nullable default=ok/first delete: AppUser | nullable legacy=ok/first delete: AppUser | mandatory default=threw/first delete: none | mandatory legacy=threw/first delete: none
