2011-03-06 3 views
1

Oracle 레거시 데이터베이스로 작업하고 있는데 두 테이블과의 관계를 매핑하려고합니다. 불행히도 데이터베이스를 설계 한 회사는 복합 키를 사용했습니다.Nhibernate에 존재하지 않는 열의 매핑

주문 번호 (번호), 버전 및 회사의 세 가지 필드로 구성된 기본 키가있는이 테이블 (주문)이 있습니다.

<?xml version="1.0" encoding="utf-8"?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
        assembly="BpSalesOrders.Domain" 
        namespace="BpSalesOrders.Domain"> 
    <class name="Order" table="OCSAORH" mutable="false" where="OCHAMND = 0"> 
    <cache usage="read-only"/> 
    <composite-id> 
     <key-property name="Number" column="OCHORDN" type="String" length="10"></key-property> 
     <key-property name="Ver" column="OCHAMND" type="Int32"></key-property> 
     <key-property name="Company" column="OCHCOSC" type="String" length="5"></key-property> 
    </composite-id> 
    <property name="Reference" column="OCHOCNO" type="String" length="25"></property> 
    <property name="Date" column="OCHOCDT" type="Int32"></property> 
    <property name="Status" column="OCHSTA1" type="Char"></property> 
    <property name="LineOfCreditStatus" column="OCHSTA4" type="Char"></property> 
    <property name="WareHouse" column="OCHRESP" type="String"></property> 
    <set name="OrderLines" access="field.pascalcase-underscore" inverse="true" lazy="true" mutable="false"> 
     <key> 
     <column name="OCLORDN" not-null="true"/> 
     <column name="OCLAMND" not-null="true" default="0"/> 
     <column name="OCLCOSC" not-null="true"/> 
     </key> 
     <one-to-many class="OrderLine" not-found ="ignore"/> 
    </set> 
    <set name="OrderReleases" access="field.pascalcase-underscore" inverse="true" lazy="true" mutable="false"> 
     <key> 
     <column name="ORLORDINE" not-null="true" /> 
     <column name="ORLSOCIETA" not-null="true"/> 
     </key> 
     <one-to-many class="OrderRelease" not-found ="ignore"/> 
    </set> 
    </class> 
</hibernate-mapping> 

테이블에는 정확한 정확한 키 구조가 있기 때문에 잘 작동하는 OrderLines과의 관계가 있습니다. OrderReleases 관계에 문제가 있습니다. 이 테이블에는 OrderNumber, 회사 및 날짜로 구성된 기본 키가 있습니다.

<?xml version="1.0" encoding="utf-8"?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
        assembly="BpSalesOrders.Domain" 
        namespace="BpSalesOrders.Domain"> 
    <class name="OrderRelease" table="OCBPORDRIL" mutable="true"> 
    <composite-id> 
     <key-property name="Company" column="ORLSOCIETA" type ="String" length="5"></key-property> 
     <key-property name="OrderNumber" column="ORLORDINE" type ="String" length="10"></key-property> 
     <key-property name="RequestDate" column="ORLDATARICHIESTA" type ="Int32"></key-property> 
    </composite-id> 
    <property name="Status" column="ORLSTATUS" type="Char" length="1"></property> 
    <property name="StatusMessage" column="ORLSEGNALAZIONE" type="String" length="90"></property> 
    <property name="ProcessingDate" column="ORLDATAELABORA" type ="Int32"></property> 
    </class> 
</hibernate-mapping> 

관계가 한 - 투 - 많은 내가 OrderNumber를하고 회사에 테이블 주문 및 OrderRelease에 가입하고자하는 것을 고려 : 여기에는 버전이 없습니다. 예제에서와 같이 nHibernate가 시도하는 키가 맵핑하려는 키가 3 개의 필드로 구성되었다는 예외를 던집니다.

매핑 및 관계를 설정할 수 있도록 유지되지 않는 존재하지 않는 열을 만드는 방법이 있습니까?

도움이 될 것입니다.

답변

0

위조 된 열이있는보기가 생성되었습니다.