-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Discriminator value in prepared statement and batch inserts
PostPosted: Tue Nov 08, 2016 9:33 am 
Newbie

Joined: Tue Nov 08, 2016 9:19 am
Posts: 2
Hi,

I've observed that when object is being inserted using hibernate, which is in some class hierarchy and contains discriminator value then insert statement is generated as below:
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'A', ?)

Now, I am trying to do batch insert but there are different types of object involved. So, because of heterogeneous objects, different insert statements (prepare statements) are generated and couldn't get the benefit of batch insert.

Is there any way that when above prepare statement is generated it doesn't contain the discriminator value? Discriminator value should be only used at the time of replacing parameter values.

Thanks.


Top
 Profile  
 
 Post subject: Re: Descriminator value in prepared insert statement
PostPosted: Tue Nov 08, 2016 9:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Try using oredred_insert as explained in this post:

Code:
<property name="hibernate.order_inserts" value="true"/>
<property name="hibernate.order_updates" value="true"/>


Make sure that you don't bump into HHH-9864 which is fixed only in 5.2.4.


Top
 Profile  
 
 Post subject: Re: Discriminator value in prepared statement and batch inserts
PostPosted: Wed Nov 09, 2016 3:05 am 
Newbie

Joined: Tue Nov 08, 2016 9:19 am
Posts: 2
Hi,

Thanks for your reply. I've already set both the properties
Code:
order_inserts, order_updates
to true.

The issue is let's say, 1 object contains heterogeneous data, so when I save that object, prepared insert statements are generated in following order.
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'A', ?)
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'B', ?)
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'C', ?)

Now, when multiple objects are being inserted, insert statements are generated as follows
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'A', ?)
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'B', ?)
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'C', ?)

insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'A', ?)
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'B', ?)
insert into TABLE (COL1, COL2, CLASS_, ID_) values (?, ?, 'C', ?)

Due to this (different prepared statement), it seems I cannot get the advantage of batch insert, in which one prepared statement is generated and then single insert statement with multiple values.
So, I was thinking that if somehow when prepared statement is generated if we can ignore the discriminator value and while actually inserting values considers the discriminator value. This way it would be possible to get the advantage of batch insert.

Event when single object is being inserted and if somehow, we eliminate discriminator value from prepared statement then in above example only 1 insert prepared statement would be created and execute statement would contain multiple values.

Thanks,


Top
 Profile  
 
 Post subject: Re: Discriminator value in prepared statement and batch inserts
PostPosted: Wed Nov 09, 2016 5:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Try with Hibernate ORM 5.2.4 and see if the fix for HHH-9864 addresses your issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.