java - hibernate native query variable -


i trying write native query:

@namednativequery(name = "getuncheckedtests",     query = "select t.test_name test_name, q.question question, @counter \\:= count(ua.is_checked=0) uncheckedanswers user_answer ua" +             " join result r on r.id = ua.result_id" +             " join test t on r.test_id = t.id" +             " join question q on ua.question_id = q.id" +             " r.is_checked = false , q.is_open = true , ua.is_checked = false" +             " , r.test_id in (select t.id result r" +             " join test t on t.id = r.test_id" +             " join user u on u.id = r.user_id" +             " r.permission = 2 , u.id = :userid) , r.permission = 1 , @counter > 0" +             " group ua.question_id") 

however, getting empty result @counter > 0 not work properly. can execute query right in workbench, no result if it's put in hibernate native query

you should check actual sql hibernate executes enabling logging of statements or using log4jdbc , make sure execute query proper parameters.


Comments