Package org.hibernate

Examples of org.hibernate.Session.connection()


  public void testBorrowedConnections() throws Throwable {
    prepare();
    Session s = getSessionUnderTest();

    Connection conn = s.connection();
    assertTrue( ( ( SessionImpl ) s ).getJDBCContext().getConnectionManager().hasBorrowedConnection() );
    conn.close();
    assertFalse( ( ( SessionImpl ) s ).getJDBCContext().getConnectionManager().hasBorrowedConnection() );

    release( s );
View Full Code Here


    cmp.put( "a", new Integer(1) );
    cmp.put( "b", new Float(1.0) );
    map.put("cmp", cmp);
    s.save(map);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession().getSession(EntityMode.MAP);
    map = (Map) s.get( "TestMap", (Serializable) map.get("id") );
    assertTrue( map!=null && "foo".equals( map.get("name") ) );
View Full Code Here

    assertTrue( map!=null && "foo".equals( map.get("name") ) );
    assertTrue( map.get("$type$").equals("TestMap") );

    int size = s.createCriteria("TestMap").add( Example.create(map) ).list().size();
    assertTrue(size==1);
    s.connection().commit();
    s.close();

    s = openSession().getSession(EntityMode.MAP);
    List list = s.createQuery("from TestMap").list();
    map = (Map) list.get(0);
View Full Code Here

    map.put("name", "foobar");
    map.put("parent", map);
    List bag = (List) map.get("children");
    bag.add(map);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    list = s.createQuery("from TestMap tm where tm.address = 'bar'").list();
    map = (Map) list.get(0);
View Full Code Here

      .size();
    assertTrue(size==1);

    s.delete(map);
    s.flush();
    s.connection().commit();
    s.close();

  }

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

    child.put("$type$", "ChildMap");
    parent.put("child", child);
    parent.put("$type$", "ParentMap");
    s.save(parent);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    Map cm = (Map) s.createQuery("from ChildMap cm where cm.parent is not null").uniqueResult();
    s.delete(cm);
View Full Code Here

    s = openSession();
    Map cm = (Map) s.createQuery("from ChildMap cm where cm.parent is not null").uniqueResult();
    s.delete(cm);
    s.delete( cm.get("parent") );
    s.flush();
    s.connection().commit();
    s.close();

    child = new HashMap();
    parent = new HashMap();
    s = openSession();
View Full Code Here

    child.put("$type$", "ChildMap");
    parent.put("child", child);
    parent.put("$type$", "ParentMap");
    s.save(child);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    Map pm = (Map) s.createQuery("from ParentMap cm where cm.child is not null").uniqueResult();
    s.delete(pm);
View Full Code Here

    s = openSession();
    Map pm = (Map) s.createQuery("from ParentMap cm where cm.child is not null").uniqueResult();
    s.delete(pm);
    s.delete( pm.get("child") );
    s.flush();
    s.connection().commit();
    s.close();

  }

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

    s.createQuery("from Commento c where c.marelo.id.mlmag = 0").list();
    s.createQuery("from Commento c where c.marelo.commento.id = c.id").list();
    s.createQuery("from Commento c where c.marelo.commento.mclink = c.mclink").list();
    s.createQuery("from Marelo m where m.commento.id > 0").list();
    s.createQuery("from Marelo m where m.commento.marelo.commento.marelo.mlmag is not null").list();
    s.connection().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.