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;
}
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;
}
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;
}
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();
}
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);
}
Aggregations