nearestNeighbor returns only 1 result

View: New views
3 Messages — Rating Filter:   Alert me  

nearestNeighbor returns only 1 result

by Mark Robinson-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So I have this snippet of code

      ReadAllQuery raq = new ReadAllQuery(NavteqPoiBean.class);
      ExpressionBuilder eb = raq.getExpressionBuilder();
      SpatialParameters parameters = new SpatialParameters();


      Expression spatialExp =
SpatialExpressionFactory.nearestNeighbor(eb.get("geom"), geom, parameters);

      raq.setSelectionCriteria(spatialExp);
      raq.prepareForExecution();
      Session session = ((EntityManagerImpl)getEm()).getSession();
      List<RowInterface> pois = (List)session.executeQuery(raq);

When I run it, I only get one result which I think is wrong, the table
has about 7000 rows.  Does EclipseLink not support returning more than
one result from this query or am I doing this wrong?

Mark

--
Mark Robinson, EIT - Mizar LLC
mark.robinson@...
111-1010 McKenzie Ave.
Victoria, BC
V8X 4B2
(360) 296-4125

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: nearestNeighbor returns only 1 result

by tware :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mark,

   Try turning our logging to the FINEST level and take a look at the generated
SQL.  Does it look correct?  When you run it in an SQL console, does it return
more than one result?

   Use the persistence unit property eclipselink.logging.level=FINEST to set the
logging level.

-Tom

Mark Robinson wrote:

> So I have this snippet of code
>
>      ReadAllQuery raq = new ReadAllQuery(NavteqPoiBean.class);
>      ExpressionBuilder eb = raq.getExpressionBuilder();
>      SpatialParameters parameters = new SpatialParameters();
>
>
>      Expression spatialExp =
> SpatialExpressionFactory.nearestNeighbor(eb.get("geom"), geom, parameters);
>
>      raq.setSelectionCriteria(spatialExp);
>      raq.prepareForExecution();
>      Session session = ((EntityManagerImpl)getEm()).getSession();
>      List<RowInterface> pois = (List)session.executeQuery(raq);
>
> When I run it, I only get one result which I think is wrong, the table
> has about 7000 rows.  Does EclipseLink not support returning more than
> one result from this query or am I doing this wrong?
>
> Mark
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: nearestNeighbor returns only 1 result

by Mark Robinson-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Tom,

Here is the generated SQL
SELECT POI_ID, POINM_LANGCODE, ACTUAL_ADDRESS, GEOMETRY, STREET_NAME,
FACILITY_TYPE, POI_NAMETYPE, LINK_ID, CHAIN_ID, POI_ST_SIDE,
VANITY_CITY, POI_ST_NUMBER, PHONE_NUMBER, POI_NAME, ST_LANGCODE,
ACCESS_TYPE FROM POI WHERE (MDSYS.SDO_NN(GEOMETRY, ?, ?) = ?)

bind => [JGeometry (gtype=3, dim=2, srid=41100, null, TRUE]


When I run the query
select * from POI where MDSYS.SDO_NN(GEOMETRY, <geom data>, '') = 'TRUE';

I get one result.  To get multiple results I have to pass
'sdo_num_res=10' as the parameter.  So I altered my SpatialParameters to
pass the new parameters and it worked.  I think note should be added to
the documentation.

Mark


Tom Ware wrote:

> Hi Mark,
>
>   Try turning our logging to the FINEST level and take a look at the
> generated SQL.  Does it look correct?  When you run it in an SQL
> console, does it return more than one result?
>
>   Use the persistence unit property eclipselink.logging.level=FINEST
> to set the logging level.
>
> -Tom
>
> Mark Robinson wrote:
>> So I have this snippet of code
>>
>>      ReadAllQuery raq = new ReadAllQuery(NavteqPoiBean.class);
>>      ExpressionBuilder eb = raq.getExpressionBuilder();
>>      SpatialParameters parameters = new SpatialParameters();
>>
>>
>>      Expression spatialExp =
>> SpatialExpressionFactory.nearestNeighbor(eb.get("geom"), geom,
>> parameters);
>>
>>      raq.setSelectionCriteria(spatialExp);
>>      raq.prepareForExecution();
>>      Session session = ((EntityManagerImpl)getEm()).getSession();
>>      List<RowInterface> pois = (List)session.executeQuery(raq);
>>
>> When I run it, I only get one result which I think is wrong, the
>> table has about 7000 rows.  Does EclipseLink not support returning
>> more than one result from this query or am I doing this wrong?
>>
>> Mark
>>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@...
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


--
Mark Robinson, EIT - Mizar LLC
mark.robinson@...
111-1010 McKenzie Ave.
Victoria, BC
V8X 4B2
(360) 296-4125

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users