我需要使用 hibernate createSQlQuery() 从表中执行 select ST_AsText(column_name)
。
当我执行该查询时,它会触发一个异常
。
但是当我使用简单的 JDBC 或在我的 PGAdmin 浏览器
中执行相同的查询时,查询有效。
下面是我的查询:
select st_astext(linkPoints) from linkRoute
异常(exception):
SEVERE: ERROR: relation "linkroute" does not exist
映射文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.lnt.utility.pojo.linkRoute" table="link_route">
<id name="Id" column="id">
<generator class="assigned" />
</id>
<property name="linkName" column="link_name"/>
<property name="distance" column="distance"/>
<property name="idNo" column="idno"/>
<property name="speed" column="speed"/>
<property name="linkPoints" column="link_points"/>
</class>
</hibernate-mapping>
请帮忙
最佳答案
Hibernate 提供了一个 createSQLQuery 方法让你直接调用你的本地 SQL 语句。
我希望您应该能够使用 nativequery 处理您的查询,否则您应该使用 Hibernate Spatial。
请找到link有关 hibernate native 查询教程的更多信息。希望这会有所帮助。
关于java - PostGIS 函数不能在 java 中使用 hibernate ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20877406/