JPQL:InnerSelect 导致 PersistenceException(HibernateException:命名查询中的错误)
我尝试使用内部选择,但只得到异常“HibernateException:命名查询中的错误”
两个JPA实体:
public class A implements Serializable {
@Id
@Column(nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
public class B implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "FK_A_ID", nullable = true)
@ManyToOne
private A a;
}
此查询导致异常:
SELECT a FROM A a WHERE a.id NOT IN (SELECT b.a.id FROM B b)
但这不会导致异常:
SELECT a FROM A a WHERE a.id NOT IN (1, 2, 3)
知道出了什么问题吗?多谢...
I try to use an inner select, but get only the exception "HibernateException: Errors in named queries"
The both JPA entities:
public class A implements Serializable {
@Id
@Column(nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
public class B implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "FK_A_ID", nullable = true)
@ManyToOne
private A a;
}
This query causes the exception:
SELECT a FROM A a WHERE a.id NOT IN (SELECT b.a.id FROM B b)
But this causes no exception:
SELECT a FROM A a WHERE a.id NOT IN (1, 2, 3)
Any idea what is wrong? Thanks a lot...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因在其他输出中可见:
此错误已记录,但在异常中不可用。
The reason was visible on other output:
This error was logged and not available in the exception.