NOT IN Clause in HQL

谁说我不能喝 提交于 2019-12-12 03:13:49

问题


How to write this query in HQL:

select * from Employee where Emp_Code 
NOT IN (select Emp_Code from EmployeeAllocation);

I was unable to find any solution for this on google. I dont know how to write NOT IN clause in HQL The result should must be fetched to a List. Like this:

List<String> lst = query.list();

回答1:


I think you can do it like, As you haven't provided any information about the table structure, otherwise I would have suggested you some better query.

But here in the below shown query I am just trying to tell you about the NOT IN clause in Hibernate or hql.

list = select Emp_Code from EmployeeAllocation

Criteria criteria = DetachedCriteria.forClass(Employee.class);
criteria.add(Restrictions.not(Restrictions.in("Emp_Code", list);

return getHibernateTemplate().findByCriteria(criteria);


来源:https://stackoverflow.com/questions/9416974/not-in-clause-in-hql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!