I work with PostgreSQL and hibernate
I have this function :
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();
}
after running my project
I have this error :
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)
when I run this query :
select max(NULLIF(split_part(num_ordre_decision, '/', 3), '')::int) from decision
in database I have the correct result
for example related to this kind of data in database :
''
''
'4/35/677'
'4/35/1001'
'4/35/99'
I have 1001
but my problem is related to hibernate
try using cast as int
like below in your sql query:
String query= "select max(cast(NULLIF(split_part(num_ordre_decision, '/', 3), '') AS int)) from decision";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With