/**
  * mdsys.sdo_geometry(5, NULL, null, mdsys.sdo_elem_info_array(1,1,3),
  * mdsys.sdo_ordinate_array(1.1, 1.1, 2.2, 2.2, 3.3, 4.4)));
  */
 public JGeometry pointCluster1() {
   Object[] points =
       new Object[] {new double[] {1.1, 1.1}, new double[] {2.2, 2.2}, new double[] {3.3, 4.4}};
   return JGeometry.createMultiPoint(points, 2, 0);
 }
 public List<Lion> getAllLions() throws SQLException {
   return (List<Lion>)
       populate(
           (resultSet, collector) -> {
             String name = resultSet.getString(1);
             STRUCT position = (STRUCT) resultSet.getObject(2);
             JGeometry pointGeom = JGeometry.load(position);
             collector.add(
                 new Lion(name, pointGeom.getJavaPoint().getX(), pointGeom.getJavaPoint().getY()));
           });
 }
  /**
   * 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();
    }
  }