Return Multiple Types from a Single ibatis Query

前端 未结 1 342
耶瑟儿~
耶瑟儿~ 2021-01-23 13:10

I have a search form that needs to include results from two different tables. The tables have no relationship to each other and our separate. In my example scenario, we have gas

相关标签:
1条回答
  • 2021-01-23 13:36

    After much googling, I figured out the answer to my own question.

    The ibatis discriminator will pick between the gasStation and groceryStore classes.

    <resultMap id="searchResultMap" class="Store">
         <discriminator column="storeType" javaType="java.lang.String">
               <subMap value="grocery" resultMap="groceryStoreMap"/>
               <subMap value="gasStation" resultMap="gasStationMap"/>
         </discriminator>
    </resultMap>
    

    I would then edit my query to add storeType in the select field and create a resultMap for the groceryStore and gasStation.

    Note - to figure this out, I read this stackoverflow question.

    0 讨论(0)
提交回复
热议问题