fra*_*nco 5 postgresql hibernate
我使用 PostgreSQL 和休眠
我有这个功能:
public List getMaxNumOrder (){
String query= "select max(NULLIF(split_part(num_ordre_decision, '/', 3), '')::int) from decision";
SQLQuery sqlQuery = this.getSession().createSQLQuery(query);
return sqlQuery.list();
}
Run Code Online (Sandbox Code Playgroud)
运行我的项目后
我有这个错误:
org.hibernate.QueryException: Not all named parameters have been set: [:int] [select max(NULLIF(split_part(num_ordre_decision, '/', 3), '')::int) from decision]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:339)
at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:228)
Run Code Online (Sandbox Code Playgroud)
当我运行此查询时:
从决策中选择 max(NULLIF(split_part(num_ordre_decision, '/', 3), '')::int)
在数据库中我有正确的结果
例如与数据库中的此类数据相关:
''
''
'4/35/677'
'4/35/1001'
'4/35/99'
Run Code Online (Sandbox Code Playgroud)
我有1001
但我的问题与休眠有关
尝试cast as int在您的 sql 查询中使用如下所示:
String query= "select max(cast(NULLIF(split_part(num_ordre_decision, '/', 3), '') AS int)) from decision";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4027 次 |
| 最近记录: |