Add one-to-many module: @OneToMany in Hibernate 7.4.16.Final (unidirectional join table vs @JoinColumn vs mappedBy, Set vs List removal cost, sync helper, fetch defaults, N+1, MultipleBagFetchException fixes, id-hashCode trap)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4H5ph3J7k2MJnRuVH
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
bdae169002
commit
eab5461d86
@@ -0,0 +1,59 @@
|
||||
# Removing ONE child: statements sent, per mapping
|
||||
# Hibernate ORM 7.4.16.Final, H2, JDK 25
|
||||
Each row: mapping | children before | statements on remove(one) + flush() | of which DELETE | of which INSERT | of which UPDATE
|
||||
|
||||
== 5 children
|
||||
join table, List (bag) | 5 | writes= 6 | delete=2 insert=4 update=0
|
||||
-- join table, List, n=5
|
||||
sql> select jlp1_0.id from JtListParent jlp1_0 where jlp1_0.id=?
|
||||
sql> select c1_0.JtListParent_id,c1_1.id,c1_1.name from JtListParent_JtChild c1_0 join JtChild c1_1 on c1_1.id=c1_0.children_id where c1_0.JtListParent_id=?
|
||||
sql> delete from JtListParent_JtChild where JtListParent_id=?
|
||||
sql> insert into JtListParent_JtChild (JtListParent_id,children_id) values (?,?)
|
||||
sql> insert into JtListParent_JtChild (JtListParent_id,children_id) values (?,?)
|
||||
sql> insert into JtListParent_JtChild (JtListParent_id,children_id) values (?,?)
|
||||
sql> insert into JtListParent_JtChild (JtListParent_id,children_id) values (?,?)
|
||||
sql> delete from JtChild where id=?
|
||||
join table, Set | 5 | writes= 2 | delete=2 insert=0 update=0
|
||||
-- join table, Set, n=5
|
||||
sql> select jsp1_0.id from JtSetParent jsp1_0 where jsp1_0.id=?
|
||||
sql> select c1_0.JtSetParent_id,c1_1.id,c1_1.name from JtSetParent_JtChild c1_0 join JtChild c1_1 on c1_1.id=c1_0.children_id where c1_0.JtSetParent_id=?
|
||||
sql> delete from JtSetParent_JtChild where JtSetParent_id=? and children_id=?
|
||||
sql> delete from JtChild where id=?
|
||||
@JoinColumn, List (bag) | 5 | writes= 2 | delete=1 insert=0 update=1
|
||||
-- @JoinColumn, List, n=5
|
||||
sql> select jlp1_0.id from JcListParent jlp1_0 where jlp1_0.id=?
|
||||
sql> select c1_0.parent_id,c1_0.id,c1_0.name from JcChild c1_0 where c1_0.parent_id=?
|
||||
sql> update JcChild set parent_id=null where parent_id=? and id=?
|
||||
sql> delete from JcChild where id=?
|
||||
@JoinColumn + @OrderColumn, remove FIRST | 5 | writes= 10 | delete=1 insert=0 update=9
|
||||
-- @OrderColumn, remove first, n=5
|
||||
sql> select op1_0.id from OcParent op1_0 where op1_0.id=?
|
||||
sql> select c1_0.parent_id,c1_0.pos,c1_0.id,c1_0.name from OcChild c1_0 where c1_0.parent_id=?
|
||||
sql> update OcChild set parent_id=null,pos=null where parent_id=? and id=?
|
||||
sql> update OcChild set parent_id=null,pos=null where parent_id=? and id=?
|
||||
sql> update OcChild set parent_id=null,pos=null where parent_id=? and id=?
|
||||
sql> update OcChild set parent_id=null,pos=null where parent_id=? and id=?
|
||||
sql> update OcChild set parent_id=null,pos=null where parent_id=? and id=?
|
||||
sql> update OcChild set parent_id=?,pos=? where id=?
|
||||
sql> update OcChild set parent_id=?,pos=? where id=?
|
||||
sql> update OcChild set parent_id=?,pos=? where id=?
|
||||
sql> update OcChild set parent_id=?,pos=? where id=?
|
||||
sql> delete from OcChild where id=?
|
||||
bidirectional mappedBy, List (bag) | 5 | writes= 1 | delete=1 insert=0 update=0
|
||||
-- bidirectional, List, n=5
|
||||
sql> select bld1_0.id from BiListDept bld1_0 where bld1_0.id=?
|
||||
sql> select e1_0.dept_id,e1_0.id,e1_0.name from BiListEmp e1_0 where e1_0.dept_id=?
|
||||
sql> delete from BiListEmp where id=?
|
||||
bidirectional mappedBy, Set | 5 | writes= 1 | delete=1 insert=0 update=0
|
||||
-- bidirectional, Set, n=5
|
||||
sql> select d1_0.id,d1_0.name from departments d1_0 where d1_0.id=?
|
||||
sql> select e1_0.dept_id,e1_0.id,e1_0.name,e1_0.uuid from employees e1_0 where e1_0.dept_id=?
|
||||
sql> delete from employees where id=?
|
||||
|
||||
== 50 children
|
||||
join table, List (bag) | 50 | writes= 51 | delete=2 insert=49 update=0
|
||||
join table, Set | 50 | writes= 2 | delete=2 insert=0 update=0
|
||||
@JoinColumn, List (bag) | 50 | writes= 2 | delete=1 insert=0 update=1
|
||||
@JoinColumn + @OrderColumn, remove FIRST | 50 | writes=100 | delete=1 insert=0 update=99
|
||||
bidirectional mappedBy, List (bag) | 50 | writes= 1 | delete=1 insert=0 update=0
|
||||
bidirectional mappedBy, Set | 50 | writes= 1 | delete=1 insert=0 update=0
|
||||
Reference in New Issue
Block a user