use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class MemoryQueryReturnConfirmedTest method test.
@Override
public void test() {
ReadAllQuery queryAllCopy = (ReadAllQuery) queryAll.clone();
// read from cache only
queryAllCopy.checkCacheOnly();
queryAllCopy.setSelectionCriteria(new ExpressionBuilder().get("address").get("city").equal("Montreal"));
inMemoryResult = (Vector) getSession().executeQuery(queryAllCopy);
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class MemoryQueryTriggerIndirectionTest method test.
@Override
public void test() {
ReadAllQuery queryAllCopy = (ReadAllQuery) queryAll.clone();
// read from cache only
queryAllCopy.checkCacheOnly();
queryAllCopy.setSelectionCriteria(new ExpressionBuilder().get("address").get("city").notEqual("Montreal"));
inMemoryResult = (Vector) getSession().executeQuery(queryAllCopy);
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class StructConverterTestSuite method testSimpleReadQuery.
/**
* Tests if SpatialExpressions will work properly without hung up when using ANYINTERACT query type
*/
public void testSimpleReadQuery() {
if (supported) {
JGeometry circle = JGeometry.createCircle(-10, 0, 0, 10, 10, 0, 0);
JGeometry newCircle = JGeometry.createCircle(0, -10, 0, 10, 10, 0, 0);
EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
try {
beginTransaction(em);
SimpleSpatial simpleSpatial = new SimpleSpatial(2000, circle);
em.persist(simpleSpatial);
commitTransaction(em);
} catch (RuntimeException ex) {
if (isTransactionActive(em)) {
rollbackTransaction(em);
}
throw ex;
}
clearCache(STRUCT_CONVERTER_PU);
ReadAllQuery raq = new ReadAllQuery(SimpleSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
SpatialParameters parameters = new SpatialParameters();
parameters.setQueryType(SpatialParameters.QueryType.WINDOW).setMask(Mask.ANYINTERACT);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("jGeometry"), newCircle, parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
getServerSession(STRUCT_CONVERTER_PU).executeQuery(raq);
// now read using jpql - should generate the same sql as the ReadAllQuery above.
clearCache(STRUCT_CONVERTER_PU);
Query query = em.createQuery("SELECT ss FROM SimpleSpatial ss WHERE FUNC('MDSYS.SDO_RELATE', ss.jGeometry, :otherGeometry, :params) = 'TRUE' ORDER BY ss.id ASC");
query.setParameter("otherGeometry", newCircle);
query.setParameter("params", parameters.getParameterString());
query.getResultList();
}
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDOFilterRectangle.
/**
* SDO_Filter using a dynamic rectangular window with lower left
* and upper right coordinates of {(1,1), (20,20)}
*/
public void testSDOFilterRectangle() throws Exception {
String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where mdsys.sdo_filter(" + "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)), " + "'QUERYTYPE=WINDOW') = '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.setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.filter(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);
}
use of org.eclipse.persistence.queries.ReadAllQuery 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