HQL中的NOT IN子句 [英] NOT IN Clause in HQL
本文介绍了HQL中的NOT IN子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在HQL中编写此查询:
How to write this query in HQL:
select * from Employee where Emp_Code
NOT IN (select Emp_Code from EmployeeAllocation);
我无法在google上找到任何解决方案。
我不知道如何在HQL
中编写NOT IN子句结果应该被提取到列表中。像这样:
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();
推荐答案
我认为你可以这样做,没有提供关于表结构的任何信息,否则我会建议你更好的查询。
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.
但是在下面的查询中,我只是想告诉你一些关于Hibernate或hql中的NOT IN子句。
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);
这篇关于HQL中的NOT IN子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文