我在 hibernate 中有以下查询:
session.createQuery("FROM RegionFile T1 WHERE (T1.action = 'MODIFY' or T1.action = 'CREATE' or (T1.action = 'NONE' " +
"AND T1.docid NOT IN (SELECT T2.docid FROM RegionFile T2 WHERE T2.action in ( 'MODIFY','DELETE')))) " +
"AND T1.rgndoc like '%" + dgId + "%'")
但是,我收到以下错误:
查询语法异常
我在这里做错了什么?
答案 0 :(得分:1)
I tried in MySql database and it successfully execute have used below query...please try again and check carefully spaces.
Query query = session.createQuery("FROM Region T1 WHERE (T1.action = 'MOD' or T1.action = 'CRT' or (T1.action = 'NON' " +
"AND T1.id NOT IN (SELECT T2.id FROM Region T2 WHERE T2.action in ( 'MOD','DEL')))) " +
"AND T1.rgndoc like '%" + dgId + "%'");
List<Region> list = query.list();
Iterator<Region> itr = list.iterator();
System.out.println("before calling");
while(itr.hasNext())
System.out.println(itr.next().getAction());
答案 1 :(得分:0)
我想通过关注你的问题来建议。
createQuery(“FROM RegionFile T1 WHERE(T1.action ='MODIFY'或T1.action ='CREATE'或(T1.action ='NONE'”+“AND T1.docid NOT IN(SELECT T2.docid FROM) RegionFile T2 WHERE T2.action in('MODIFY','DELETE')))“+”AND T1.rgndoc like'%“+ a +”%')“)