我使用本机查询来调用我的 postgresql 数据库中的函数,代码是这样的:
String query = "select details,rec_xml[1] from f_get_reccomendations(\'/ma:recommendations/ma:recommendation/name/text()\') ORDER BY id DESC LIMIT 1;";
Query q = em.createNativeQuery(query);
return q.getResultList();
函数定义为:
CREATE OR REPLACE FUNCTION f_get_reccomendations (
IN xpath varchar(128),
OUT id int,
OUT recs_num int,
OUT details varchar(25),
OUT d_stamp timestamp,
OUT rec_xml xml[]
) RETURNS SETOF RECORD AS
$$
select id, recs_num, details, d_stamp, xpath($1, recs,
array [
array['xs','http://www.w3.org/2001/XMLSchema'],
array['ma','http://schemas.medio.com/analytics/1.0']
]
) from recommendations;
$$
LANGUAGE SQL;
当从 psql 运行时,它可以工作,但是当我在代码中运行时,它给我带来了错误:没有 JDBC 类型的方言映射:2009
我的猜测是 rec_xml 被定义为休眠无法理解的 xml[] 类型?我该如何解决?谢谢