2012-04-11 3 views
0

개체 및 SlabPDO SlabInstructions에 대한 매핑 참조가있는 슬래브 개체에 대한 매핑이 있습니다. 나는 선택을하고 싶습니다. 항상 SlabPDO 객체를 가지고 있어야하고 필요할 때만 SlabInstructions를로드하십시오. 이 일을 할 수있는 방법이 있습니까?필요한 경우에만 개체로드

<id name="Id" column="Id_Slab" type="Int64"> 
    <generator class="Geraes.GLib.GDomainBasis.CustomTableHiLoGenerator, GLib.GDomainBasis" /> 
</id> 

<property name="Mill" column="Mill" type="String" length="2" not-null="true" /> 

<property name="SlabId" column="Slab_Id" type="String" length="20" not-null="true" /> 

<property name="PieceId" column="Piece_Id" type="String" length="20" not-null="true" /> 

<one-to-one name="SlabPDO" class="SlabPDO" cascade="all" fetch="join"/> 

<set name="SlabInstructions" generic="true" inverse="true" lazy="false" cascade="all" fetch="join"> 
    <key column="Id_Slab" /> 
    <one-to-many class="SlabInstruction"/> 
</set> 

베스트 감사합니다 : 매핑의 예를 아래에! 이 두 가지 매핑 속성 lazy="true"fetch="select"이 문서 http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/performance.html#performance-fetching

상담에 관한

+1

하십시오입니다. – ChrisF

답변

0

여기에 영어로 제목을 번역 할 수있는 솔루션

<set name="SlabInstructions" generic="true" inverse="true" lazy="true" cascade="all" 
    fetch="select"> 
    <key column="Id_Slab" /> 
    <one-to-many class="SlabInstruction"/> 
</set> 
+0

답장을 보내 주셔서 감사합니다! 문제의 90 %에서 자식 개체가 필요합니다. 다른 경우에는 자식 객체의로드를 무시해야합니다. 최선의 접근 방법은 무엇입니까? –

+1

쿼리를 작성할 때 하위 객체를로드하도록 지정할 수 있습니다 ('left join fetch'). 따라서 매핑은 10 %의 경우에 자식 객체의 불필요한로드를 줄이기 위해 게으르게 될 수 있습니다. – bpgergo

관련 문제