Package org.hibernate.classic

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


    s.close();

    s = openSession();
    t = s.beginTransaction();

    Connection connection = s.connection();
    PreparedStatement statement = connection.prepareStatement("SELECT * FROM STRANGE_TYPED_OBJECT WHERE ID=?");
    statement.setInt(1, id.intValue());
    ResultSet resultSet = statement.executeQuery();

    assertTrue("A row should have been returned", resultSet.next());
View Full Code Here


  ) {
    String oldsql = oldQueryTranslator.getSQLString();
    String newsql = newQueryTranslator.getSQLString();

    Session session = openSession();
    Connection connection = session.connection();

    PreparedStatement oldps = null;
    PreparedStatement newps = null;
    ResultSet oldrs = null;
    ResultSet newrs = null;
View Full Code Here

    c = (Category) s.load(Category.class, id);
    s.refresh(c);
    s.flush();
    assertTrue( c.getSubcategories().size()==1 );
    s.flush();
    s.connection().commit();
    s.close();
    s = openSession();
    c = (Category) s.load(Category.class, id);
    assertTrue( c.getSubcategories().size()==1 );
    s.delete(c);
View Full Code Here

    s = openSession();
    c = (Category) s.load(Category.class, id);
    assertTrue( c.getSubcategories().size()==1 );
    s.delete(c);
    s.flush();
    s.connection().commit();
    s.close();
  }

  public void testCachedCollectionRefresh() throws Exception {
    if ( isSerializableIsolationEnforced() ) {
View Full Code Here

    c.setSubcategories(list);
    list.add( new Category() );
    c.setName("root");
    Serializable id = s.save(c);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    c = (Category) s.load(Category.class, id);
    c.getSubcategories().size(); //force load and cache
View Full Code Here

    s.close();

    s = openSession();
    c = (Category) s.load(Category.class, id);
    c.getSubcategories().size(); //force load and cache
    s.connection().commit();
    s.close();
   
    s = openSession();
    if ( (getDialect() instanceof MySQLDialect) ) {
      s.connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
View Full Code Here

    s.connection().commit();
    s.close();
   
    s = openSession();
    if ( (getDialect() instanceof MySQLDialect) ) {
      s.connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    }
    c = (Category) s.load(Category.class, id);
    c.getSubcategories().size(); //force load

    Session ss = openSession();
View Full Code Here

    Session ss = openSession();
    Category c2 = (Category) ss.load(Category.class, id);
    ss.delete( c2.getSubcategories().get(0) );
    c2.getSubcategories().clear();
    ss.flush();
    ss.connection().commit();
    ss.close();

    s.refresh(c);
    assertTrue( c.getSubcategories().size()==0 );
View Full Code Here

    ss = openSession();
    c2 = (Category) ss.load(Category.class, id);
    c2.getSubcategories().add( new Category() );
    c2.getSubcategories().add( new Category() );
    ss.flush();
    ss.connection().commit();
    ss.close();

    s.refresh(c);
    assertEquals( 2, c.getSubcategories().size() );
View Full Code Here

  public void testInterface() throws Exception {
    Session s = openSession();
    Serializable id = s.save( new BasicNameable() );
    s.flush();
    s.connection().commit();
    s.close();
    s = openSession();
    Nameable n = (Nameable) s.load(Nameable.class, id);
    s.delete(n);
    s.flush();
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.