-->
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: locking issues
PostPosted: Fri Apr 16, 2010 3:53 pm 
Newbie

Joined: Fri Apr 16, 2010 3:50 pm
Posts: 3
I have a script that runs for hours sending out large email campaigns..

I have a table called "Email" and a table called "Sent" there is a FK in sent that references the email table..

I have a large for loop, that loops thru all the contacts the email is to be sent to, it creates a new Sent entity for every email that is sent

The problem I am having is that currently I commit the transaction every 100 emails.. which can take a few minutes to do.. and during that time the email row is locked.. is there any way to make hibernate not lock that row?

Here is some sample code to make this more clear?? hopefully?

Code:
private void process(Email email, List<Contact> contacts)
{
    et.begin();

    int counter = 0;

    for (Contact contact : contacts)
    {
        Sent sent = new Sent();
        sent.setEmail(email);
        sent.setUuid(UUID.randomUUID().toString();
        sent.setDate(new Date());
        sent.setContact(contact);
        em.persist(sent);

        // this uses the uuid and contact from the sent entity
        send(email, sent);

        counter++;

        if (counter % 100 == 0)
        {
            et.commit();
            et.begin();
        }
    }

    et.commit();
}


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.