-->
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.  [ 1 post ] 
Author Message
 Post subject: Batch the Update statements
PostPosted: Thu Oct 29, 2015 12:21 pm 
Newbie

Joined: Thu Oct 29, 2015 11:58 am
Posts: 1
Hi,
I'm executing several update statements like so:
Code:
for (Entity entity : entities) {
    String queryString = "update Entity set property1 = :property1 " +
            "where objectId = :objectId";
    Query query = em.createQuery(queryString)
            .setParameter("property1", someValue)
            .setParameter("objectId", someId);
    query.executeUpdate();
}

I want them to be batched, so single DB roundtrip is done.
I've set "hibernate.jdbc.batch_size" to "50".
I see no batching takes place.

Although, when I do:
Code:
for (Entity entity : entities) {
    entity.setProperty1(someValue);
}

(entities are managed/persistent)
then, at the time of commit later, the batch happens.

Can I batch with the update statements?

I'm using Hibernate 4.3.1 via JPA API.


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

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.