-->
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.  [ 2 posts ] 
Author Message
 Post subject: When did Batching Insert statements introduce many rows?
PostPosted: Thu Apr 20, 2017 11:57 am 
Regular
Regular

Joined: Wed Jan 21, 2009 8:41 pm
Posts: 54
My project uses hibernate-core 3.3.1.GA,
entity-manager 3.4.0.GA

As you can see I'm dealing with legacy code.

Which Hibernate release introduced batch inserts where by the convention is
multiple rows specified for a single insert into statement?

ie. this example from Vlad's book.

“Query: ["INSERT INTO post (title, id) VALUES (?, ?)"],
Params: [('Post no. 1', 1), ('Post no. 2', 2), ('Post no. 3', 3)]”

as opposed to

“INSERT INTO post (title, id) VALUES ('Post no. 1', 1)”
“INSERT INTO post (title, id) VALUES ('Post no. 2', 2)”
“INSERT INTO post (title, id) VALUES ('Post no. 3', 3) ”

also I have some batching where I put something in a collection and I either periodically flush
the collection by persisting all it's elements and then committing or explicitly persist it when the batch size is reached. Because the timer uses a scheduled executor this involves a synchronized block around the collection
which isn't optimal but ensures exclusivity when operating on the batch.

If a batch doesn't process what are the options to allow it to call persist on the same objects again?

1. always process a batch so I must clear my collection if I've previously persist? so I'm expected
to always handle the batch whether successful or not?

Otherwise next time it tries to process the collection I end up processing a detached object.

What alternatives to this are there?


Top
 Profile  
 
 Post subject: Re: When did Batching Insert statements introduce many rows?
PostPosted: Thu Apr 20, 2017 12:15 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Check out this Quora answer which is similar to your problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.