使用 hibernate-entitymanager 4.2.8.Final hibernate-spatial 4.0
Session session = sessionProvider.get();
Criteria criteria = session.createCriteria(UEntity.class);
criteria.add(SpatialRestrictions.contains("geometry", point));
List<UEntity> containedByMbr = criteria.list();
我得到以下例外情况。任何建议都非常值得注意。
java.lang.IllegalStateException: Dialect must be spatially enabled dialect
at org.hibernate.spatial.criterion.SpatialRelateExpression.toSqlString(SpatialRelateExpression.java:106)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:419)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:123)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:92)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:95)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1568)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:490)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Jul 13, 2014 2:09:13 PM com.sun.jersey.spi.container.ContainerResponse logException
SEVERE: Mapped exception to response: 500 (Internal Server Error)
答案 0 :(得分:0)
此错误的含义是您的数据库方言不支持空间限制。
Hibernate无法将SpatialRestriction
转换为数据库的SQL,因为该数据库方言不支持Spatial操作。
更改数据库或强制将Hibernate的方言强制为支持空间操作的方言。