Package org.hibernate

Examples of org.hibernate.Session.lock()


    session.close();
   
   
    session = openSession();
    t = session.beginTransaction();
    session.lock(prod, LockMode.READ);
    prod.getParts().remove(part);
    t.commit();
    session.close();
   
    session = openSession();
View Full Code Here


    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    s.lock( p, LockMode.UPGRADE );
    s.lock( q, LockMode.UPGRADE );
    s.delete( p );
    s.delete( q );
    t.commit();
    s.close();
View Full Code Here

    s.close();

    s = openSession();
    t = s.beginTransaction();
    s.lock( p, LockMode.UPGRADE );
    s.lock( q, LockMode.UPGRADE );
    s.delete( p );
    s.delete( q );
    t.commit();
    s.close();
View Full Code Here

    // perform the isolated update
    s1 = getSessions().openSession();
    t1 = s1.beginTransaction();
    item = ( Item ) s1.get( Item.class, itemId );
    s1.lock( item, LockMode.UPGRADE );
    item.setName( "updated" );
    s1.flush();

    Session s2 = getSessions().openSession();
    Transaction t2 = s2.beginTransaction();
View Full Code Here

    long initialVersion = item.getVersion();

    s1 = getSessions().openSession();
    t1 = s1.beginTransaction();
    item = ( Item ) s1.get( Item.class, itemId );
    s1.lock( item, LockMode.FORCE );
    assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );

    myEntity = (MyEntity) s1.get( MyEntity.class, myEntity.getId() );
    s1.lock( myEntity, LockMode.FORCE );
    assertTrue( "LockMode.FORCE on a unversioned entity should degrade nicely to UPGRADE", true );
View Full Code Here

    item = ( Item ) s1.get( Item.class, itemId );
    s1.lock( item, LockMode.FORCE );
    assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );

    myEntity = (MyEntity) s1.get( MyEntity.class, myEntity.getId() );
    s1.lock( myEntity, LockMode.FORCE );
    assertTrue( "LockMode.FORCE on a unversioned entity should degrade nicely to UPGRADE", true );


    s1.lock( item, LockMode.FORCE );
    assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );
View Full Code Here

    myEntity = (MyEntity) s1.get( MyEntity.class, myEntity.getId() );
    s1.lock( myEntity, LockMode.FORCE );
    assertTrue( "LockMode.FORCE on a unversioned entity should degrade nicely to UPGRADE", true );


    s1.lock( item, LockMode.FORCE );
    assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );

    Session s2 = getSessions().openSession();
    Transaction t2 = s2.beginTransaction();
    Item item2 = ( Item ) s2.get( Item.class, itemId );
View Full Code Here

    TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));

    s = factory.openSession();
    s.setCacheMode( CacheMode.IGNORE );
    t = s.beginTransaction();
    s.lock(doc, LockMode.NONE);
    TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
    TestCase.assertEquals( doc.getText(), "blah blah" );
    TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "text"));
    t.commit();
    s.close();
View Full Code Here

    session.close();
   
   
    session = openSession();
    t = session.beginTransaction();
    session.lock(prod, LockMode.READ);
    prod.getParts().remove(part);
    t.commit();
    session.close();
   
    session = openSession();
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    s.lock( p, LockMode.UPGRADE );
    s.lock( q, LockMode.UPGRADE );
    s.delete( p );
    s.delete( q );
    t.commit();
    s.close();
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.