Package org.hibernate.classic

Examples of org.hibernate.classic.Session.lock()


    s = openSession();
    t = s.beginTransaction();
    multi = (Multi) s.load( Top.class, multiId, LockMode.UPGRADE );
    simp = (Top) s.load( Top.class, simpId );
    s.lock(simp, LockMode.UPGRADE_NOWAIT);
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
View Full Code Here


    s = openSession();
    list = s.find("from Fum fum where not fum.fum='FRIEND'");
    assertTrue( "deleted owner", list.size()==2 );
    s.lock( list.get(0), LockMode.UPGRADE );
    s.lock( list.get(1), LockMode.UPGRADE );
    Iterator iter = list.iterator();
    while ( iter.hasNext() ) {
      s.delete( iter.next() );
    }
    s.flush();
View Full Code Here

    s3 = (Simple) s.load(Simple.class, new Long(3), LockMode.READ);
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE );
    s4 = (Simple) s.load(Simple.class, new Long(4), LockMode.UPGRADE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.UPGRADE_NOWAIT );

    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE);
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE );
    s.lock(s1, LockMode.UPGRADE_NOWAIT);
    s.lock(s4, LockMode.NONE);
View Full Code Here

    s4 = (Simple) s.load(Simple.class, new Long(4), LockMode.UPGRADE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.UPGRADE_NOWAIT );

    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE);
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE );
    s.lock(s1, LockMode.UPGRADE_NOWAIT);
    s.lock(s4, LockMode.NONE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.UPGRADE_NOWAIT );
View Full Code Here

    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE);
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE );
    s.lock(s1, LockMode.UPGRADE_NOWAIT);
    s.lock(s4, LockMode.NONE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.UPGRADE_NOWAIT );

    tx.commit();
    tx = s.beginTransaction();
View Full Code Here

    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE);
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE );
    s.lock(s1, LockMode.UPGRADE_NOWAIT);
    s.lock(s4, LockMode.NONE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.UPGRADE_NOWAIT );

    tx.commit();
    tx = s.beginTransaction();
View Full Code Here

    assertTrue( s.getCurrentLockMode(s3)==LockMode.NONE );
    assertTrue( s.getCurrentLockMode(s1)==LockMode.NONE );
    assertTrue( s.getCurrentLockMode(s2)==LockMode.NONE );
    assertTrue( s.getCurrentLockMode(s4)==LockMode.NONE );

    s.lock(s1, LockMode.READ); //upgrade
    assertTrue( s.getCurrentLockMode(s1)==LockMode.READ );
    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE_NOWAIT); //upgrade
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE_NOWAIT );
View Full Code Here

    assertTrue( s.getCurrentLockMode(s2)==LockMode.NONE );
    assertTrue( s.getCurrentLockMode(s4)==LockMode.NONE );

    s.lock(s1, LockMode.READ); //upgrade
    assertTrue( s.getCurrentLockMode(s1)==LockMode.READ );
    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE_NOWAIT); //upgrade
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE_NOWAIT );
    s.lock(s4, LockMode.NONE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.NONE );
View Full Code Here

    s.lock(s1, LockMode.READ); //upgrade
    assertTrue( s.getCurrentLockMode(s1)==LockMode.READ );
    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE_NOWAIT); //upgrade
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE_NOWAIT );
    s.lock(s4, LockMode.NONE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.NONE );

    s4.setName("s4");
View Full Code Here

    assertTrue( s.getCurrentLockMode(s1)==LockMode.READ );
    s.lock(s2, LockMode.UPGRADE); //upgrade
    assertTrue( s.getCurrentLockMode(s2)==LockMode.UPGRADE );
    s.lock(s3, LockMode.UPGRADE_NOWAIT); //upgrade
    assertTrue( s.getCurrentLockMode(s3)==LockMode.UPGRADE_NOWAIT );
    s.lock(s4, LockMode.NONE);
    assertTrue( s.getCurrentLockMode(s4)==LockMode.NONE );

    s4.setName("s4");
    s.flush();
    assertTrue( s.getCurrentLockMode(s4)==LockMode.WRITE );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.