I am trying out the code at link
http://vladmihalcea.com/how-to-batch-insert-and-update-statements-with-hibernate/ with 5.0.4.
I have just set the below properties
Code:
properties.put("hibernate.jdbc.batch_size","15");
properties.put("hibernate.order_inserts", "true");
properties.put("hibernate.order_updates", "true");
and I still see the INSERT and the UPDATE statements are properly batched even without setting the below property
properties.put("hibernate.jdbc.batch_versioned_data", "true");
The output I see is:
Code:
insert into BatchPost (title, version, id) values (?, ?, ?)"], Params:[(1=Post1,2=0,3=326),(1=Post2,2=0,3=329)]
insert into BatchComment (post_id, review, version, id) values (?, ?, ?, ?)"], Params:[(1=326,2=Post11,3=0,4=327),(1=326,2=Post12,3=0,4=328),(1=329,2=Post21,3=0,4=330),(1=329,2=Post22,3=0,4=331)]
select post0_.id as id1_1_0_, comments1_.id as id1_0_1_, post0_.title as title2_1_0_, post0_.version as version3_1_0_, comments1_.post_id as post_id4_0_1_, comments1_.review as review2_0_1_, comments1_.version as version3_0_1_, comments1_.post_id as post_id4_0_0__, comments1_.id as id1_0_0__ from BatchPost post0_ inner join BatchComment comments1_ on post0_.id=comments1_.post_id"], Params:[()]
update BatchComment set post_id=?, review=?, version=? where id=? and version=?"], Params:[(1=326,2=Post11ModifiedModified,3=1,4=327,5=0),(1=326,2=Post12ModifiedModified,3=1,4=328,5=0),(1=329,2=Post21ModifiedModified,3=1,4=330,5=0),(1=329,2=Post22ModifiedModified,3=1,4=331,5=0)]
update BatchPost set title=?, version=? where id=? and version=?"], Params:[(1=Post1ModifiedModified,2=1,3=326,4=0),(1=Post2ModifiedModified,2=1,3=329,4=0)]
I am wondering, shouldn't this value should be treated as false by default as per hibernate documentation.