在Morphia中搜索多边形内的点会引发验证异常

时间:2017-10-14 03:46:36

标签: mongodb morphia

我将Morphia与MongoDB结合使用。我正在使用地理空间示例餐馆和社区。特别是我想搜索给定社区(Polygon)的餐馆(位置)。

以下是查询:

query.field("location")
    .within(polygon);

此处字段“location”是Morphia Point。例外情况是:

Oct 13, 2017 8:04:17 PM org.mongodb.morphia.mapping.Mapper toMongoObject
SEVERE: Error converting <br> value(Polygon{exteriorBoundary=LineString{coordinates=[Point{coordinates=[-73.94732672160579, 40.62916656720943]} ... ... Point{coordinates=[-73.94732672160579, 40.62916656720943]}]}, interiorBoundaries=[]}) to reference.
java.lang.NullPointerException
    at org.mongodb.morphia.mapping.Mapper.toMongoObject(Mapper.java:634)
    at org.mongodb.morphia.query.FieldCriteria.<init>(FieldCriteria.java:64)
    at org.mongodb.morphia.query.FieldCriteria.<init>(FieldCriteria.java:31)
    at org.mongodb.morphia.query.StandardGeoFieldCriteria.<init>(StandardGeoFieldCriteria.java:30)
    at org.mongodb.morphia.query.FieldEndImpl.intersects(FieldEndImpl.java:161)
    at org.mongodb.morphia.query.FieldEndImpl.intersects(FieldEndImpl.java:1)
at com.example.mongodb.dao.impl.RestaurantDAOImpl.getRestaurantsInNeighborhood(RestaurantDAOImpl.java:47)

0 个答案:

没有答案