Examples of ScrollableResults


Examples of org.hibernate.ScrollableResults

    t = s.beginTransaction();
    s.setDefaultReadOnly( true );
    DataPoint dpLast = ( DataPoint ) s.get( DataPoint.class,  dp.getId() );
    assertTrue( s.isReadOnly( dpLast ) );
    int i = 0;
    ScrollableResults sr = s.createQuery("from DataPoint dp order by dp.x asc")
        .setReadOnly(false)
        .scroll(ScrollMode.FORWARD_ONLY);
    int nExpectedChanges = 0;
    while ( sr.next() ) {
      dp = (DataPoint) sr.get(0);
      if ( dp.getId() == dpLast.getId() ) {
        //dpLast existed in the session before executing the read-only query
        assertTrue( s.isReadOnly( dp ) );
      }
      else {
View Full Code Here

Examples of org.hibernate.ScrollableResults

    assertTrue( "Incorrect result size", iter.hasNext() );
    obj = iter.next();
    assertTrue( "Incorrect return type", obj instanceof Map );
    assertEquals( "Incorrect return type", ( (Map) obj ).size(), 2 );

    ScrollableResults sr = session.createQuery( "select new map(an.description, an.bodyWeight) from Animal an" ).scroll();
    assertTrue( "Incorrect result size", sr.next() );
    obj = sr.get(0);
    assertTrue( "Incorrect return type", obj instanceof Map );
    assertEquals( "Incorrect return type", ( (Map) obj ).size(), 2 );
    sr.close();

    sr = session.createQuery( "select new Animal(an.description, an.bodyWeight) from Animal an" ).scroll();
    assertTrue( "Incorrect result size", sr.next() );
    assertTrue( "Incorrect return type", sr.get(0) instanceof Animal );
    sr.close();

    // caching...
    QueryStatistics stats = getSessions().getStatistics().getQueryStatistics( "select new Animal(an.description, an.bodyWeight) from Animal an" );
    results = session.createQuery( "select new Animal(an.description, an.bodyWeight) from Animal an" )
        .setCacheable( true )
View Full Code Here

Examples of org.hibernate.ScrollableResults

    session.close();

    session = openSession();

    ScrollableResults sr = session.createQuery( query )
       .setResultTransformer(Transformers.aliasToBean(Animal.class)).scroll();
    assertTrue( "Incorrect result size", sr.next() );
    assertTrue( "Incorrect return type", sr.get(0) instanceof Animal );
    assertFalse(session.contains(sr.get(0)));
    sr.close();

    session.close();

    session = openSession();
View Full Code Here

Examples of org.hibernate.ScrollableResults

    session.close();

    session = openSession();

    ScrollableResults sr = session.createQuery( query )
       .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).scroll();
    assertTrue( "Incorrect result size", sr.next() );
    assertTrue( "Incorrect return type", sr.get(0) instanceof Map );
    assertFalse(session.contains(sr.get(0)));
    sr.close();

    session.close();

    destroyTestBaseData();
  }
View Full Code Here

Examples of org.hibernate.ScrollableResults

    course.setCourseCode("HIB");
    course.setDescription("Hibernate Training");
    session.persist(course);
    session.flush();
    session.clear();
    ScrollableResults sr = session.createCriteria(Course.class).setReadOnly( true ).scroll();
    assertTrue( sr.next() );
    course = (Course) sr.get(0);
    assertNotNull(course);
    assertTrue( session.isReadOnly( course ) );
    sr.close();
    session.delete(course);
   
    t.commit();
    session.close();
   
View Full Code Here

Examples of org.hibernate.ScrollableResults

    SimpleJtaTransactionManagerImpl.getInstance().getTransaction().commit();

    // First, test partially scrolling the result with out closing
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = getSessions().getCurrentSession();
    ScrollableResults results = s.createQuery( "from Item" ).scroll();
    results.next();
    SimpleJtaTransactionManagerImpl.getInstance().getTransaction().commit();

    // Next, test partially scrolling the result with closing
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = getSessions().getCurrentSession();
    results = s.createQuery( "from Item" ).scroll();
    results.next();
    results.close();
    SimpleJtaTransactionManagerImpl.getInstance().getTransaction().commit();

    // Next, scroll the entire result (w/o closing)
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = getSessions().getCurrentSession();
    results = s.createQuery( "from Item" ).scroll();
    while ( results.next() ) {
      // do nothing
    }
    SimpleJtaTransactionManagerImpl.getInstance().getTransaction().commit();

    // Next, scroll the entire result (closing)
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = getSessions().getCurrentSession();
    results = s.createQuery( "from Item" ).scroll();
    while ( results.next() ) {
      // do nothing
    }
    results.close();
    SimpleJtaTransactionManagerImpl.getInstance().getTransaction().commit();

    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = getSessions().getCurrentSession();
    s.createQuery( "delete from Item" ).executeUpdate();
View Full Code Here

Examples of org.hibernate.ScrollableResults

      public List transformList(List arg0)
      {
        return arg0;
      }
    });
    ScrollableResults sr = q.scroll();
    sr.first();
    Object[] row = sr.get();
    assertEquals(1, row.length);
    Object obj = row[0];
    assertTrue(obj instanceof PartnerA);
    PartnerA obj2 = (PartnerA) obj;
    assertEquals("Partner A", obj2.getName());
View Full Code Here

Examples of org.hibernate.ScrollableResults

    set.add("Simple 1"); set.add("foo");
    q.setParameterList( "name_list", set );
    q.setParameter("count", new Integer(-1) );
    assertTrue( q.list().size()==1 );

    ScrollableResults sr = s.createQuery("from Simple s").scroll();
    sr.next();
    sr.get(0);
    sr.close();

    s.delete(other);
    s.delete(simple);
    s.delete(min);
    t.commit();
View Full Code Here

Examples of org.hibernate.ScrollableResults

    set.add("Simple 1"); set.add("foo");
    q.setParameterList( "name_list", set );
    q.setParameter("count", new Integer(-1) );
    assertTrue( q.list().size()==1 );

    ScrollableResults sr = s.createQuery("from Simple s").scroll();
    sr.next();
    sr.get(0);
    sr.close();

    s.delete(other);
    s.delete(simple);
    s.delete(min);
    t.commit();
View Full Code Here

Examples of org.hibernate.ScrollableResults

    assertEquals( "unexpected execution count", 2, continentStats.getExecutionCount() );
    // but should not effect the cumulative row count
    assertEquals( "unexpected row count", results, continentStats.getExecutionRowCount() );
    Hibernate.close( itr );

    ScrollableResults scrollableResults = s.createQuery( continents ).scroll();
    // same deal with scroll()...
    assertEquals( "unexpected execution count", 3, continentStats.getExecutionCount() );
    assertEquals( "unexpected row count", results, continentStats.getExecutionRowCount() );
    // scroll through data because SybaseASE15Dialect throws NullPointerException
    // if data is not read before closing the ResultSet
    while ( scrollableResults.next() ) {
      // do nothing
    }
    scrollableResults.close();
    tx.commit();
    s.close();

    // explicitly check that statistics for "split queries" get collected
    // under the original query
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.