Package org.hibernate.classic

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


    loaded = (Category) s.load( Category.class, new Long( c.getId() ) );
    assertFalse( Hibernate.isInitialized( loaded.getSubcategories() ) );
    s.connection().commit();
    s.close();
    s = openSession();
    s.lock(loaded, LockMode.NONE);
    assertTrue( loaded.getSubcategories().size()==2 );
    s.connection().commit();
    s.close();

View Full Code Here


    getSessions().evict(Glarch.class);

    s = openSession();
    txn = s.beginTransaction();
    g = (GlarchProxy) s.load( Glarch.class, gid );
    s.lock(g, LockMode.UPGRADE);
    g2 = (GlarchProxy) s.load( Glarch.class, g2id );
    assertTrue( "version", g.getVersion()==1 );
    assertTrue( "version", g.getDerivedVersion()==1 );
    assertTrue( "version", g2.getVersion()==0 );
    g.setName("foo");
View Full Code Here

    getSessions().evict(Glarch.class);

    s = openSession();
    txn = s.beginTransaction();
    g = (GlarchProxy) s.load( Glarch.class, gid );
    s.lock(g, LockMode.UPGRADE);
    g2 = (GlarchProxy) s.load( Glarch.class, g2id );
    assertTrue( "version", g.getVersion()==1 );
    assertTrue( "version", g.getDerivedVersion()==1 );
    assertTrue( "version", g2.getVersion()==0 );
    g.setName("foo");
View Full Code Here

    j = (J) s.get(I.class, jid);
    j = (J) s.get(J.class, jid);
    i = (I) s.get(I.class, iid);
    assertTrue( i.getClass()==I.class );
    j.setAmount( 0.5f );
    s.lock(i, LockMode.UPGRADE);
    s.flush();
    s.connection().commit();
    s.close();

    getSessions().evict(I.class);
View Full Code Here

    j = (J) s.get(J.class, jid);
    j = (J) s.get(I.class, jid);
    i = (I) s.get(I.class, iid);
    assertTrue( i.getClass()==I.class );
    j.setAmount( 0.5f );
    s.lock(i, LockMode.UPGRADE);
    s.flush();
    s.connection().commit();
    s.close();

    getSessions().evict(I.class);
View Full Code Here

    j = (J) s.get(I.class, jid);
    j = (J) s.get(J.class, jid);
    i = (I) s.get(I.class, iid);
    assertTrue( i.getClass()==I.class );
    j.setAmount( 0.5f );
    s.lock(i, LockMode.UPGRADE);
    s.flush();
    s.connection().commit();
    s.close();

    getSessions().evict(I.class);
View Full Code Here

    j = (J) s.get(J.class, jid);
    j = (J) s.get(I.class, jid);
    i = (I) s.get(I.class, iid);
    assertTrue( i.getClass()==I.class );
    j.setAmount( 0.5f );
    s.lock(i, LockMode.UPGRADE);
    s.flush();
    s.connection().commit();
    s.close();

    getSessions().evict(I.class);
View Full Code Here

    getSessions().evict(Glarch.class);

    s = openSession();
    txn = s.beginTransaction();
    g = (GlarchProxy) s.load( Glarch.class, gid );
    s.lock(g, LockMode.UPGRADE);
    g2 = (GlarchProxy) s.load( Glarch.class, g2id );
    assertTrue( "version", g.getVersion()==1 );
    assertTrue( "version", g.getDerivedVersion()==1 );
    assertTrue( "version", g2.getVersion()==0 );
    g.setName("foo");
View Full Code Here

    getSessions().evict(Glarch.class);

    s = openSession();
    txn = s.beginTransaction();
    g = (GlarchProxy) s.load( Glarch.class, gid );
    s.lock(g, LockMode.UPGRADE);
    g2 = (GlarchProxy) s.load( Glarch.class, g2id );
    assertTrue( "version", g.getVersion()==1 );
    assertTrue( "version", g.getDerivedVersion()==1 );
    assertTrue( "version", g2.getVersion()==0 );
    g.setName("foo");
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

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.