Hibernate继承:加载所有实体但不加载子类

时间:2016-11-10 11:02:17

标签: java hibernate inheritance

给出两个班级

@Entity
@Table(name = "A")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class A{
...
}

@Entity
@Table(name = "B")
public class B extends A{
...
}

致电

SessionFactory sessionFactory = ...;
Session session = sessionFactory.openSession();
session.createCriteria(A.class).list()

我收到了A B的所有实例。

如何仅查询A的实例(没有A的子类)?

0 个答案:

没有答案