연관 테이블을 통해 관련된 개체를 선택하기위한 조건 쿼리를 만들려고합니다.Hibernate Criteria Query - 속성을 가진 many-to-many를 검색하는 방법?
Insurer * - 1 Insurer_Section 1 - * Section
InsurerSection의 연관 속성은 active : bool입니다.
InsurerSection 클래스의 활성 속성이 true로 설정된 모든 Insurer를 얻으려면 어떻게해야합니까?
PS :이처럼 갈 수 없어 :
Insurer.FindAll(
DetachedCriteria.For<Insurer>().CreateCriteria("Insurer_Section").Add(Expression.Eq("Active", true)
);
Insurer_Section는 hasAndBelongsToMany의를 통해 매핑되는 연관 테이블이기 때문에 :
[HasAndBelongsToMany(typeof(Section), Table = "`Insurer_Section`",
ColumnKey = "`IdInsurer`", ColumnRef = "`IdSection`",
Cascade = ManyRelationCascadeEnum.AllDeleteOrphan)]
private IList<Section> Sections {
get { return this.sections; }
set { this.sections = value; }
}
및
[HasAndBelongsToMany(typeof(Insurer), Table = "`Insurer_Section`",
ColumnKey = "`IdSection`", ColumnRef = "`IdInsurer`",
Cascade = ManyRelationCascadeEnum.None, Inverse = true)]
public IList<Insurer> Insurers {
get { return this.insurers; }
set { this.insurers = value; }
}