在hibernate中如何使用not in子句 [英] In hibernate how to use not in clause

查看:132
本文介绍了在hibernate中如何使用not in子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表

工作和生产

生产表有jobid字段,作业表。

production table has jobid field which refers jobid of jobs table.

在hibernate中如何使用not in子句

In hibernate how to use not in clause

来实现以下sql查询

SELECT * FROM job where job_id not in(select job_id from production);

SELECT * FROM jobs where job_id not in (select job_id from production);

推荐答案

你可以使用HQL:

List<Job> jobs = session.createQuery(
        "from Job where id not in (select jobId from Production)"
    ).list();

这篇关于在hibernate中如何使用not in子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆