Search in sources :

Example 6 with ReadAllQuery

use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.

the class ReadAllFirstResultVsRownumFilteringTest method addReadAllRownumFilteringTest.

/**
 * Read all employees with scrollable cursor.
 */
public void addReadAllRownumFilteringTest() {
    PerformanceComparisonTestCase test = new PerformanceComparisonTestCase() {

        @Override
        public void test() {
            ReadAllQuery query = new ReadAllQuery(Employee.class);
            query.setFirstResult(size - 1);
            getSession().executeQuery(query);
        }
    };
    test.setName("ReadAllRownumFilteringTest");
    test.setAllowableDecrease(350);
    addTest(test);
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) PerformanceComparisonTestCase(org.eclipse.persistence.testing.framework.PerformanceComparisonTestCase)

Example 7 with ReadAllQuery

use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.

the class ReadAllMaxRowsFirstResultVsRownumFilteringTest method test.

/**
 * Read all employees with cursored stream.
 */
@Override
public void test() throws Exception {
    ReadAllQuery query = new ReadAllQuery(Employee.class);
    getSession().executeQuery(query);
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery)

Example 8 with ReadAllQuery

use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.

the class ReadAllMaxRowsFirstResultVsRownumFilteringTest method addReadAllRownumFilteringTest.

/**
 * Read all employees with scrollable cursor.
 */
public void addReadAllRownumFilteringTest() {
    PerformanceComparisonTestCase test = new PerformanceComparisonTestCase() {

        @Override
        public void test() {
            ReadAllQuery query = new ReadAllQuery(Employee.class);
            query.setMaxRows(maxrows);
            query.setFirstResult(maxrows - 1);
            getSession().executeQuery(query);
        }
    };
    test.setName("ReadAllRownumFilteringTest");
    test.setAllowableDecrease(300);
    addTest(test);
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) PerformanceComparisonTestCase(org.eclipse.persistence.testing.framework.PerformanceComparisonTestCase)

Example 9 with ReadAllQuery

use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.

the class UnitOfWorkConformWithOrderTest method test.

@Override
public void test() {
    // Make a query an search Number greaterThan "00005"
    ExpressionBuilder phone = new ExpressionBuilder();
    Expression exp = phone.get("areaCode").equal(613);
    ReadAllQuery query = new ReadAllQuery(PhoneNumber.class);
    query.setSelectionCriteria(exp);
    // set Conforming
    query.conformResultsInUnitOfWork();
    query.addOrdering(phone.get("owner").get("id").descending());
    query.addOrdering(phone.get("type").descending());
    UnitOfWork uow = getSession().acquireUnitOfWork();
    Vector v = (Vector) uow.executeQuery(query);
    Vector v2 = (Vector) uow.executeQuery(query);
    if (!v.equals(v2)) {
        throw new TestErrorException("Order not maintained when conforming:" + v + " != " + v2);
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Expression(org.eclipse.persistence.expressions.Expression) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) Vector(java.util.Vector)

Example 10 with ReadAllQuery

use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.

the class ScrollableCursorJoinedAttributeTest method test.

@Override
public void test() {
    if (getSession().getPlatform().isHANA() || getSession().getPlatform().isSQLServer()) {
        throw new TestWarningException("ScrollableCursor is not supported on this platform");
    }
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    cursoredResults = new Vector();
    ReadAllQuery cursoredQuery = new ReadAllQuery(Employee.class);
    cursoredQuery.useScrollableCursor();
    cursoredQuery.addJoinedAttribute(cursoredQuery.getExpressionBuilder().anyOfAllowingNone("phoneNumbers"));
    cursoredQuery.addOrdering(cursoredQuery.getExpressionBuilder().get("id"));
    try {
        ScrollableCursor cursor = (ScrollableCursor) getSession().executeQuery(cursoredQuery);
        while (cursor.hasNext()) {
            Object result = cursor.next();
            cursoredResults.add(result);
        }
        cursor.close();
    } catch (Exception e) {
        caughtException = e;
    }
}
Also used : ScrollableCursor(org.eclipse.persistence.queries.ScrollableCursor) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) Vector(java.util.Vector) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException)

Aggregations

ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)440 Expression (org.eclipse.persistence.expressions.Expression)278 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)265 List (java.util.List)202 EntityManager (jakarta.persistence.EntityManager)135 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)119 Vector (java.util.Vector)112 ArrayList (java.util.ArrayList)88 Spatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial)82 SpatialParameters (org.eclipse.persistence.expressions.spatial.SpatialParameters)81 Employee (org.eclipse.persistence.testing.models.jpa.advanced.Employee)62 ReportQuery (org.eclipse.persistence.queries.ReportQuery)57 SimpleSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)47 WrappedSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial)44 SQLReader (org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader)41 JGeometry (oracle.spatial.geometry.JGeometry)30 CriteriaBuilder (jakarta.persistence.criteria.CriteriaBuilder)29 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)28 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)27 Query (jakarta.persistence.Query)25