Package org.hibernate.classic

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


    assertEquals(
        "cached object identity",
        im,
        s.createQuery( "from Immutable im where im = ?" ).setParameter( 0, im, Hibernate.entity(Immutable.class) ).uniqueResult()
    );
    s.connection().createStatement().executeUpdate("delete from immut");
    s.getTransaction().commit();
    s.close();
  }

  public void testFindLoad() throws Exception {
View Full Code Here


    Session s = openSession();
    s.beginTransaction();
    Foo foo = new Foo();
    s.save(foo);
    s.flush();
    s.connection().createStatement().executeUpdate("update "+getDialect().openQuote()+"foos"+getDialect().closeQuote()+" set long_ = -3");
    s.refresh(foo);
    assertTrue( foo.getLong().longValue()==-3l );
    assertTrue( s.getCurrentLockMode(foo)==LockMode.READ );
    s.refresh(foo, LockMode.UPGRADE);
    if ( getDialect().supportsOuterJoinForUpdate() ) {
View Full Code Here

    g.setStrings(list);
    HashSet set = new HashSet();
    set.add(g);
    g.setProxySet(set);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( g.getStrings().size()==1 );
View Full Code Here

    assertTrue( g.getStrings().size()==1 );
    assertTrue( g.getProxyArray().length==1 );
    assertTrue( g.getProxySet().size()==1 );
    assertTrue( "versioned collection before", g.getVersion()==1 );
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( g.getStrings().get(0).equals("foo") );
View Full Code Here

    assertTrue( g.getStrings().get(0).equals("foo") );
    assertTrue( g.getProxyArray()[0]==g );
    assertTrue( g.getProxySet().iterator().next()==g );
    assertTrue( "versioned collection before", g.getVersion()==1 );
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection before", g.getVersion()==1 );
View Full Code Here

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection before", g.getVersion()==1 );
    g.getStrings().add("bar");
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection after", g.getVersion()==2 );
View Full Code Here

    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection after", g.getVersion()==2 );
    assertTrue( "versioned collection after", g.getStrings().size()==2 );
    g.setProxyArray(null);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection after", g.getVersion()==3 );
View Full Code Here

    assertTrue( "versioned collection after", g.getVersion()==3 );
    assertTrue( "versioned collection after", g.getProxyArray().length==0 );
    g.setFooComponents( new ArrayList() );
    g.setProxyArray(null);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection after", g.getVersion()==4 );
View Full Code Here

    g = (GlarchProxy) s.load(Glarch.class, gid);
    assertTrue( "versioned collection after", g.getVersion()==4 );
    s.delete(g);
    s.flush();
    assertTrue( s.createQuery( "from java.lang.Object" ).list().size()==0 );
    s.connection().commit();
    s.close();
  }

  /*public void testVersionedSubcollections() throws Exception {
    Session s = sessionsopenSession();
View Full Code Here

    baz = (Baz) s2.load(Baz.class, baz.getCode());
    assertTrue( ( (Long) s2.createQuery( "select count(*) from Bar" ).iterate().next() ).longValue()==3 );
    s2.delete(baz);
    s2.delete( baz.getTopGlarchez().get( new Character('G') ) );
    s2.delete( baz.getTopGlarchez().get( new Character('H') ) );
    int rows = s2.connection().createStatement().executeUpdate("update " + getDialect().openQuote() + "glarchez" + getDialect().closeQuote() + " set baz_map_id=null where baz_map_index='a'");
    assertTrue(rows==1);
    assertEquals( 2, doDelete( s2, "from Bar bar" ) );
    FooProxy[] arr = baz.getFooArray();
    assertTrue( "new array of objects", arr.length==4 && arr[1].getKey().equals( foo.getKey() ) );
    for ( int i=1; i<arr.length; i++ ) {
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.