Hibernation lock table

Seam 2.2, Jboss 6.1, hibernate 3.5.6 and MSQL Server 2008

and have such a function.

public void deliverFile() {
    EntityManager jobbEntityManager = (EntityManager)Component.getInstance("jobbEntityManager");

    JobbStatusInterface jobbStatus = new JobbStatus();
    jobbStatus.setStatus(PluginStatus.INITIATED);
    jobbEntityManager.persist(jobbStatus);


            /**

                 Code here to save a file that takes a minutes
             **/





    jobbStatus.setStatus(PluginStatus.DONE);
    jobbEntityManager.flush();





    }
    public void checkJobb(){
    EntityManager jobbEntityManager =  (EntityManager)Component.getInstance("jobbEntityManager");

        jobbEntityManager.createQuery("from JobbStatus", JobbStatus.class).getResultList();


    }

I have a poll on checkJobb every 10 seconds, so if the deliveryFile () function is executed.

checkJobb is the upp queue and stops in the request, so when the deliveryFile () functions end, it completes all 6 checkJobbs () at once.

Even if I select directly from the database, it is locked and completes its request after delivery of File ().

Anyway, to do this so that I can execute my checkJobb () while deliveryFile is running?

+3
source share
2 answers

READ_COMMITTED_SNAPSHOT instead of the usual READ_COMMITTED isolation.

ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE; 
ALTER DATABASE <dbname> SET READ_COMMITTED_SNAPSHOT ON; 
ALTER DATABASE <dbname> SET MULTI_USER; 
0
source

, , . , , .. . , ... .

.

0

All Articles