는 다음 매핑 항목 가정 아이디 이외의 열을 마스터 - 세부 가입 :>NHibernate에 내부
< 클래스 명 = "고객"테이블 = "고객"
<id name="InternalId" column="uintCustomerId" type="long">
<generator class="identity" />
</id>
<!-- The BinaryBlob below is a 16 byte array - Think Guid.NewGuid().ToByteArray -->
<property name="CustomerUid" column="uidCustomerId" type="BinaryBlob" not-null="true" />
<property name="Name" column="strFullName" type="String" not-null="true" />
<property name="Age" column="intAge" type="System.Int32" not-null="true" />
<set name="Orders" table="order" generic="true" inverse="false" lazy="false" cascade="all">
<key column="uidCustomerId" />
<one-to-many class="Order" />
</set>
< 클래스 이름 = "주문"테이블 = "주문">
<id name="InternalId" column="uintOrderId" type="long">
<generator class="identity" />
</id>
<!-- This BinaryBlob is a 16 byte array - Think Guid.NewGuid().ToByteArray -->
<property name="CustomerUid" column="uidCustomerId" type="BinaryBlob" not-null="true" />
<property name="OrderDate" column="datOrderDate" type="System.DateTime" not-null="true" />
그래서 2 클래스 : 고객 - 주문 속성은 위의 매핑
고객의 PK가 uintCustomerId
기사단 PK가
uidCustomerId은 고객 테이블에 고유 키에 고객에게 FK이다 uintOrderId
입니다에 정의 된 주문 테이블 uidCustomerId는 이진수입니다.데이터베이스를 변경할 수 없습니다.
상기를 감안할 때. Hibernate Criteria API를 사용하여 어떻게 질의하여 주어진 날짜 이후에 고객과 그의 관련 주문을 가져올 수 있습니까? 참고 : 기본 키가 아닌 uidCustomerId에 가입해야합니다.
Criteria API로 수행 할 수있는 작업인가요? HQL을 사용하여이 작업을 수행 할 수 있습니까?
덕분에, Tasos
에 대한 좋은 참고입니다. 매핑이 이미있는 경우 단순한 Customer.Orders 속성을 통해 주문을 참조하는 것보다 고객을 정상적으로 처리하는 것이 어떻습니까? –
귀하의 의견을 보내 주셔서 감사합니다 Mufasa 고객이 특정 날짜 이후 주문을 원한다면 어떻게 하시겠습니까? – Anastasiosyal