2012-06-12 3 views
2

iBatis resultMap에서 누락 된 열을 어떻게 무시할 수 있습니까? 나는이 매퍼 내가 열 F2를 반환 할 일부 쿼리에 대한누락 된 열 무시

<resultMap id="DBEntity" class="CS_Entity"> 
    <result property="Id" column="Id" /> 
    <result property="Field1" column="f1" /> 
    <result property="Field2" column="f2" /> 
</resultMap> 

이있는 경우

하지만 어떻게 기본값으로 다른 모든 쿼리 필드 F2를 추가하지 않고 선언 할 수 있습니다.

방법이 있습니까?

답변

1

사용이 f2

<resultMap id="DBEntityWithF2" class="CS_Entity"> 
    <result property="Id" column="Id" /> 
    <result property="Field1" column="f1" /> 
    <result property="Field2" column="f2" /> 
</resultMap> 

와 서로 resultsMap 하나 f2

<resultMap id="DBEntity" class="CS_Entity"> 
    <result property="Id" column="Id" /> 
    <result property="Field1" column="f1" /> 
</resultMap> 
1

없이 당신은 단순히 당신의 SQL에 "select f2 as Field2 from yourTable"을 사용할 수 있으며, 대신 구성 resultMap를 사용하는 resultClass="CS_Entity"를 사용합니다. 이런 식으로 위와 같이 매핑을 선언 할 필요는 없습니다.

관련 문제