Menu

extending resultMap

2004-09-07
2004-09-09
  • Greg Fitzgerald

    Greg Fitzgerald - 2004-09-07

    is there a way to do this.
    e.g rather than do
    <resultMap id="sql1" class="aClass">
      <result property="one" column="one"/>
    </resultMap>

    <resultMap id="sql2" class="aClass">
      <result property="one" column="one"/>
      <result property="two" column="two"/>
    </resultMap>

    instead do
    <resultMap id="sql2" extendId ="sql1" class="aClass">
      <result property="two" column="two"/>
    </resultMap>

    in order to avoid duplication.

     
    • Ted Husted

      Ted Husted - 2004-09-07

      The attribute you are looking for is "extends":

      <resultMap id=resultMapName class=some.domain.Class [extends=parent-resultMap]>
      <result property=propertyName column=COLUMN_NAME
      [columnIndex=1] [javaType=int] [jdbcType=NUMERIC]
      [nullValue=-999999] [select=someOtherStatement]
      />
      <result />
      <result />
      <result />
      </resultMap>

      (from page 22 of DevGuide 2)

      In the C# implementation, we are experimenting with using extends with a parameterMap, since the difference between an Insert and an Update is often whether an additional field is specified (for the WHERE clause).

      -Ted.

       
    • Greg Fitzgerald

      Greg Fitzgerald - 2004-09-09

      Thanks Ted, BTW, i found your struts book excellent

       

Log in to post a comment.