如何通过Hibernate执行PostgreSQL的sequence manipulation functions,例如setVal()
?例如:
SELECT setval('license_req_seq', (select max (id)+1 as maxVal from agents_requests))
org.hibernate.Session session = ...
session.createSQLQuery(command).executeUpdate()
答案 0 :(得分:0)
如果要获取setval过程返回值,则应使用uniqueResult():
Long nextVal = (Long)session.createSQLQuery(command).uniqueResult();