How can I use MySQL assign operator(:=) in hibernate native query?

前端 未结 6 1531
情歌与酒
情歌与酒 2020-11-28 13:13

I\'m using Hibernate. I wrote some native query because I need to use sub select statement.

Query looks like this:

SELECT sub.rownum FROM 
    (SELEC         


        
6条回答
  •  攒了一身酷
    2020-11-28 14:10

    you can implement this is a slightly different way.. you need to replace the : operator with something else (say '|' char ) and in your interceptor replace the '|' with the : .

    this way hibernate will not try to think the : is a param but will ignore it

    For the interceptor logic you can refer to the hibernate manual

    This has worked for me using MySQL 5.

    remember, this replacing of : must be only done to ':=' and other MySQL specific requirments.. don't try to replace the : for the param-placeholders. (hibernate will not be able to identify the params then)

提交回复
热议问题