简体   繁体   中英

Hibernate HQL Update Issue

I am getting one strange issue in Hibernate HQL update query. Below is the code I am using to update the table.

String update = "update SomeTable set reschEffDate=:reschEffDate,deferalFromInstl=:deferalFromInstl where loanId='"+ stageRepricing.getLoanId()+ "' and reschId='"+ stageRepricing.getReschId() + "'";
Query query = session.createQuery(update);
query.setParameter("reschEffDate",stageRepricing.getReschEffDate());
query.setParameter("deferalFromInstl", Integer.toString(stageRepricing.getDeferalFromInstl()));

Now the moment I add second column ( deferalFromInstl ) in query, I get below strange exception.

Illegal char <:> at index 17: deferalFromInstl=:deferalFromInstl.class at session.createQuery(update);

If I remove this column, the query works fine. Let me know if anyone have faced this issue and what is the cause of this issue.

I found the issue with above update statement. Actually the problem was, that there should be space between fieldname and placeholder. Like below.

String update = "update SomeTable set reschEffDate =:reschEffDate,deferalFromInstl =:deferalFromInstl where loanId =:loanId and reschId =:reschId";

After the above changes I did not get the error and table updated successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM