2017-09-01 45 views
0

即使它存在,但我得到异常无法找到命名参数。HQL:即使存在命名参数,即使它存在

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

查询

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); 

我只是不明白是什么的问题。

+0

不是一个真正的重复@Andremoniy只是一个错字问题 – DamCx

回答

1

您的查询缺少括号和values关键字。

尝试

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);