I have a mysql query like this to get the row numbers.
set @rank = 0;
select @rank := @rank + 1 as rank,id,name from test
In hibernate 3 ':=' was a problem.
session.createSQLQuery("set @rank = 0;
select @rank := @rank + 1 as rank,id,name from test");
i switch to hibernate 3 to 4 and used escape character.
session.createSQLQuery("set @rank = 0;
select @rank \\:= @rank + 1 as rank,id,name from test");
Now another exception occured. It gives the exception:
"Parameter rank does not exist as a named parameter"
I tried this:
session.createSQLQuery("select :rank \\:= :rank + 1 as rank,
ID,NAME,SURNAME from test").setInteger("rank", 0)
This time it gives this exception:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ':= 0 + 1 as rank,id,
name from test' at line 1
Any idea how can i solve this issue?