Package org.hibernate

Examples of org.hibernate.ScrollableResults.last()


    public int getRowCountByExample(User exampleUser, String... ignoreProperty) {

        Criteria crit = prepareExampleCriteria(exampleUser, null, false, ignoreProperty);
        ScrollableResults cursor = crit.scroll();
        cursor.last();
        int count = cursor.getRowNumber() + 1;
        cursor.close();
        return count;
    }
View Full Code Here


                // If it's a WikiNode, fetch the associated User instances, avoiding N+1 selects
                query = "select o from " + entityClass.getName() + " o inner join fetch o.createdBy left join fetch o.lastModifiedBy fetch all properties";
            }
            ScrollableResults cursor = ftSession.createQuery(query).scroll();

            cursor.last();
            int count = cursor.getRowNumber() + 1;
            log.debug("total documents in database: " + count);

            if (count > 0) {
                cursor.first(); // Reset to first result row
View Full Code Here

    results.afterLast();
    assertFalse( results.isFirst() );
    assertFalse( results.isLast() );
    assertFalse( results.next() );

    assertFalse( results.last() );
    assertFalse( results.isFirst() );
    assertFalse( results.isLast() );
    assertFalse( results.next() );

    for ( int i=1; i<3; i++ ) {
View Full Code Here

    results.afterLast();
    assertFalse( results.isFirst() );
    assertFalse( results.isLast() );
    assertFalse( results.next() );

    assertTrue( results.last() );
    assertTrue( results.isFirst() );
    assertTrue( results.isLast() );
    assertFalse( results.next() );

    assertTrue( results.first() );
View Full Code Here

    Object f4 = iter.get(0);
    assertTrue( f4!=null );
    assertTrue( !iter.next() );
    assertTrue( iter.first() );
    assertTrue( iter.get(0)==f1 );
    assertTrue( iter.last() );
    assertTrue( iter.get(0)==f4 );
    assertTrue( iter.previous() );
    txn.commit();
    s.close();
View Full Code Here

    f4 = iter.get(0);
    assertTrue( f4!=null );
    assertTrue( !iter.next() );
    assertTrue( iter.first() );
    assertTrue( iter.get(0)==f1 );
    assertTrue( iter.last() );
    assertTrue( iter.get(0)==f4 );
    assertTrue( iter.previous() );
    assertTrue( s.delete("from Foo")==4 );
    s.flush();
    assertTrue( s.createQuery( "from java.lang.Object" ).list().size()==0 );
View Full Code Here

    results = hibQuery.scroll();
    results.first();
    Object[] result = results.get();
    assertEquals(1004, result[0]);

    results.last();
    result = results.get();
    assertEquals(1004, result[0]);

    //cleanup
    for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
View Full Code Here

          "lastname",
          FullTextQuery.THIS
          )
      .setFetchSize( 10 )
      .scroll();
    scrollableResults.last();
    assertEquals( 132, scrollableResults.getRowNumber() );
    scrollableResults.beforeFirst();
    assertEquals( -1, scrollableResults.getRowNumber() );
    int position = scrollableResults.getRowNumber();
    while ( scrollableResults.next() ) {
View Full Code Here

    projections.next();
    Object[] projection = projections.get();
    checkProjectionFirst( projection, s );
    assertTrue( projections.isFirst() );

    projections.last();
    projection = projections.get();
    checkProjectionLast( projection, s );
    assertTrue( projections.isLast() );

    projections.next();
View Full Code Here

      .setFetchSize( 10 )
      .setFirstResult( 20 )
      .setMaxResults( 111 )
      .scroll();
    assertEquals( -1, scrollableResults.getRowNumber() );
    assertTrue( scrollableResults.last() );
    assertEquals( 110, scrollableResults.getRowNumber() );
    scrollableResults.beforeFirst();
    int position = scrollableResults.getRowNumber();
    while ( scrollableResults.next() ) {
      position++;
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.