Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not all named parameters have been set: [:int]

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

like image 780
franco Avatar asked Sep 11 '14 16:09

franco


1 Answers

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";
like image 62
user3487063 Avatar answered Nov 09 '22 13:11

user3487063