0

I am getting the exception could not locate named parameter even though it exists.

org.hibernate.QueryParameterException: could not locate named parameter [type]

Query

String query = ("insert into my_table (abc_id, dup_id,type_code) "+
                     " (abc_seq.nextval, 2,:type");
            Query myQuery = em.createNativeQuery(query);    
            nativeQuery.setParameter("type", code);

I simply dont understand what is the issue.

sTg
  • 4,313
  • 16
  • 68
  • 115

1 Answers1

1

Your query lacks a parenthesis and a values keyword.

Try

String query = ("insert into my_table (abc_id, dup_id,type_code) "+
                "values (abc_seq.nextval, 2,:type)");
Query myQuery = em.createNativeQuery(query);    
nativeQuery.setParameter("type", code);
DamCx
  • 1,047
  • 1
  • 11
  • 25