0

我尝试使用内部选择,但只得到异常“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)

知道有什么问题吗?非常感谢...

4

1 回答 1

0

原因在其他输出中可见:

QuerySyntaxException: "Tablename is not mapped"

此错误已记录,并且在异常中不可用。

于 2009-12-11T10:27:28.590 回答