0

Here is my query:

update JSNumber set runningNo=(select runningNo +1 from JSNumber where paymentDate= '2015-07-09 00:00:00.0' ) where paymentDate = '2015-07-09 00:00:00.0'

This is working fine when I set it to a StringBuilder sb, and run as follow:

Query query = getSession( ).createQuery( sb.toString( ) );

Here is my edited query:

select runningNo from final table (update JSNumber set runningNo=(select runningNo +1 from JSNumber where paymentDate= '2015-07-09 00:00:00.0' ) where paymentDate = '2015-07-09 00:00:00.0' )

I add in select runningNo from final table () in front of the original query. This is working fine when I run it in DBVisualizer, but when I want to run as hql, I hit

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 35

Kindly advise how to write it in hql query.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Panadol Chong
  • 1,793
  • 13
  • 54
  • 119

1 Answers1

0

Just found something. Use createSqlQuery() instead of createQuery() can solve this problem.

Panadol Chong
  • 1,793
  • 13
  • 54
  • 119