我尝试使用内部选择,但只获得异常“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)
知道出了什么问题吗?非常感谢...
答案 0 :(得分:0)
原因在其他输出上可见:
QuerySyntaxException: "Tablename is not mapped"
此错误已记录,但在例外中不可用。