Menu

Composite keys question

2004-11-02
2013-04-11
  • Nobody/Anonymous

    Hi,
    Is it possible to pass a string value, together with the columns, to a mapped statement in a result map?

    example:
    <result-map name="materialclassification-result" class="com.mhc.domain.MaterialClassification">
    <property name ="subsector" column="{code=SUBSECTOR_CODE,version=VERSION_CODE,typeOfClass='Material Subsector'}" mapped-statement="getClassificationDescription"/>
    <property name ="brand" column="{code=SUBSECTOR_CODE,version=VERSION_CODE,typeOfClass='Material Brand'}" mapped-statement="getClassificationDescription"/>

    The typeOfClass parameter is a string and is used in the getClassificationDescription query.

    <mapped-statement name="getClassificationDescription"
    cache-model="cr-desc-cache"
    result-class="java.lang.String">
    select DESCRIPTION from MHC_CLASSIFICATION_REFERENCES
    where VERSION_CODE = #version#
    and CODE = #code#
    and CLASS_TYPE = #typeOfClass#
    </mapped-statement>

    I'am using iBatis 1.3.1

    Cheers
    Roel

     
    • Larry Meadors

      Larry Meadors - 2004-11-04

      It would probably easier to do it in the SQL statement, then pass the parameter from there. Either way you are hard coding it, so take the simlper path.

       
    • Nobody/Anonymous

      That's the way i'am doing it now. It meens i have to define 9 maped statements with the only difference the parameterin it (in my example i only have 2 properties, but in real it are 9). So i hoped there is an other way.

       

Log in to post a comment.