0
我試圖簡單地篩選出基於OneToMany關係中的子類的ID屬性的結果,但Hibernate(4.1.9.Final)正在生成左外連接而不是內連接加入並因此返回我不想要的結果。休眠OneToMany關係內部連接
型號:
家長:
@Entity
@Table(name = "CATEGORY")
public class Category
{
@Id
@Column(name = "CATEGORYID")
private int ID;
@Column(name = "CATEGORYNAME")
private String name;
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "CATEGORYID")
@Filter(name = "TEST_RUN_ID_FILTER")
private Collection<TestCase> testCases
...
}
兒童:
@Entity
@Table(name = "TESTCASE_NEW")
@FilterDef(name = "TEST_RUN_ID_FILTER", defaultCondition = "TESTRUNID in (:IDS)", parameters = { @ParamDef(name = "IDS", type = "int") })
public class TestCase
{
@Id
@Column(name = "TESTCASEID")
private int ID;
@Column(name = "TESTCASENAME")
private String name;
@Column(name = "STATUS")
private String status;
@Column(name = "TESTRUNID")
private int testRunId;
...
}
DAO:
public List<Category> getAllCategoriesForTestRuns(List<Integer> testRunIDs)
{
Session session = getSession();
session.enableFilter("TEST_RUN_ID_FILTER")
.setParameterList("IDS", testRunIDs);
Query query = session.createQuery("FROM " + Category.class.getSimpleName());
List<Category> result = query.list();
return resul2t;
}
我如何告訴Hibernate使用內部連接?