【发布时间】:2013-12-04 17:12:45
【问题描述】:
为什么 JPA 会修改我的原生查询?
例如:
Query q = entityManager.createNativeQuery("select id from edges order by st_geomfromtext(?,4326) <#> geom_way limit 1");
q.setParameter(1, "POINT( " + longitude + " " + latitude + ")");
q.getSingleResult();
注意操作符,postgis中使用。
此代码导致错误:
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: No se ha especificado un valor para el parámetro 2.
Error Code: 0
Call: select id from edges order by st_geomfromtext(?,4326) <? geom_way limit 1
bind => [null]
Query: DataReadQuery(sql="select id from edges order by st_geomfromtext(?,4326) <? geom_way limit 1")
为什么 EclipseLink 2.5.1 将“<#>”替换为“<?”?
谢谢
【问题讨论】:
标签: java jpa eclipselink jpa-2.0 java-ee-6