Package org.hibernate

Examples of org.hibernate.Session.lock()


          // obtain update lock by default (LockMode.UPGRADE)
          LockMode lockMode = parentLockMode != null ? LockMode.parse(parentLockMode)
              : LockMode.UPGRADE;
          log.debug("acquiring " + lockMode + " lock on " + parentToken);
          // lock updates as appropriate, no need to flush here
          session.lock(parentToken, lockMode);
        }

        boolean reactivateParent = true;

        // if this is a discriminator
View Full Code Here


    Session s = factory.openSession();
    Transaction tx=null;
    try {
      tx = s.beginTransaction();

      s.lock(item, LockMode.NONE);
      s.lock(bidder, LockMode.NONE);

      Bid bid = new Bid();
      bid.setBidder(bidder);
      bid.setDatetime( new Date() );
View Full Code Here

    Transaction tx=null;
    try {
      tx = s.beginTransaction();

      s.lock(item, LockMode.NONE);
      s.lock(bidder, LockMode.NONE);

      Bid bid = new Bid();
      bid.setBidder(bidder);
      bid.setDatetime( new Date() );
      bid.setAmount(amount);
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

    session.close();


    session = openSession();
    t = session.beginTransaction();
    session.lock(prod, LockMode.READ);
    prod.getParts().remove(mapKey);
    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

    // do 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 un-versioned 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 un-versioned 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

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.