Search in sources :

Example 1 with ReportQuery

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

the class AggregateTest method getSimpleCountTest.

public static JPQLTestCase getSimpleCountTest() {
    String ejbql;
    ejbql = "SELECT COUNT(emp) FROM Employee emp";
    AggregateTest test = getNewTestCaseNamed("COUNT Test", ejbql, Employee.class);
    ReportQuery rq = getNewReportQueryForTest(test);
    rq.addCount("id", Long.class);
    return test;
}
Also used : ReportQuery(org.eclipse.persistence.queries.ReportQuery)

Example 2 with ReportQuery

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

the class AggregateTest method getComplexDistinctCountTest.

public static JPQLTestCase getComplexDistinctCountTest() {
    String ejbql;
    ejbql = "SELECT COUNT (DISTINCT emp.lastName) FROM Employee emp";
    AggregateTest test = getNewTestCaseNamed("Complex DISTINCT COUNT Test", ejbql, Employee.class);
    ReportQuery rq = getNewReportQueryForTest(test);
    rq.addCount("lastName", new ExpressionBuilder().get("lastName").distinct(), Long.class);
    return test;
}
Also used : ReportQuery(org.eclipse.persistence.queries.ReportQuery) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 3 with ReportQuery

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

the class AggregateTest method getNewReportQueryForTest.

private static ReportQuery getNewReportQueryForTest(AggregateTest test) {
    ReportQuery rq = new ReportQuery();
    rq.setReferenceClass(test.getReferenceClass());
    rq.returnSingleAttribute();
    rq.dontRetrievePrimaryKeys();
    test.setReportQuery(rq);
    return rq;
}
Also used : ReportQuery(org.eclipse.persistence.queries.ReportQuery)

Example 4 with ReportQuery

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

the class DeleteTests method countSimpleSpatial.

public static int countSimpleSpatial(Session session) {
    ReportQuery rq = new ReportQuery(SimpleSpatial.class, new ExpressionBuilder());
    rq.addCount();
    rq.setShouldReturnSingleValue(true);
    Number value = (Number) session.executeQuery(rq);
    return value.intValue();
}
Also used : ReportQuery(org.eclipse.persistence.queries.ReportQuery) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 5 with ReportQuery

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

the class Query_SpatialOp_ExpReport_Tests method testSDOWithinDistanceRectangleUsingMaxResolution.

public void testSDOWithinDistanceRectangleUsingMaxResolution() throws Exception {
    String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where mdsys.sdo_within_distance(" + "ws.geometry.geom, mdsys.sdo_geometry(3,null,null, mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'DISTANCE=10 MAX_RESOLUTION=5') = 'TRUE' ORDER BY GID";
    SQLReader reader = new SQLReader(session, sql);
    double[] points = new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 };
    populateTestGeometry(JGeometry.createLinearPolygon(points, 2, 0));
    ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    ExpressionBuilder eb2 = new ExpressionBuilder();
    ReportQuery rq = new ReportQuery(WrappedSpatial.class, eb2);
    // rq.addAttribute("geometry.geom");
    rq.addItem("geom", eb2.get("geometry").getField("geom"));
    rq.setSelectionCriteria(eb2.get("id").equal(6666));
    Expression geom1 = eb.get("geometry").getField("geom");
    SpatialParameters parameters = new SpatialParameters();
    parameters.setDistance(10d).setMaxResolution(5);
    Expression selectionCriteria = SpatialExpressionFactory.withinDistance(geom1, rq, parameters);
    selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
    raq.setSelectionCriteria(selectionCriteria);
    raq.addAscendingOrdering("id");
    List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : SQLReader(org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader) Expression(org.eclipse.persistence.expressions.Expression) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) ReportQuery(org.eclipse.persistence.queries.ReportQuery) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Aggregations

ReportQuery (org.eclipse.persistence.queries.ReportQuery)286 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)217 Expression (org.eclipse.persistence.expressions.Expression)129 List (java.util.List)84 Vector (java.util.Vector)69 EntityManager (jakarta.persistence.EntityManager)55 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)52 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)30 ArrayList (java.util.ArrayList)28 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)28 SpatialParameters (org.eclipse.persistence.expressions.spatial.SpatialParameters)26 Spatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial)26 ReportQueryResult (org.eclipse.persistence.queries.ReportQueryResult)24 DynamicEntity (org.eclipse.persistence.dynamic.DynamicEntity)21 Employee (org.eclipse.persistence.testing.models.jpa.advanced.Employee)21 Test (org.junit.Test)21 ConstantExpression (org.eclipse.persistence.internal.expressions.ConstantExpression)20 Iterator (java.util.Iterator)19 DynamicType (org.eclipse.persistence.dynamic.DynamicType)15 SimpleSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)13