Quantcast

Question: MyBatis3, How to use discriminator for like property-scope in resultMap?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question: MyBatis3, How to use discriminator for like property-scope in resultMap?

rocbin
I have four Class, the User group parent is the Company or Shop, the Class Company and Shop is implementation of IGroup.
The Entity Relationship(ER) Like this:



<resultMap id="userMap" type="org.mybatis.entity.User">
 
<id property="userId" column="UserId"/>
 
<result property="groupId" column="GroupId"/>
 
<association property="group">
   
<!-- how to coding?-->
 
</association>
</resultMap>


Is there any way, thank you!

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question: MyBatis3, How to use discriminator for like property-scope in resultMap?

Iwao AVE!
Hi,

This seems to work.

<resultMap type="org.mybatis.entity.User" id="userMap">
  <id property="userId" column="UserId" />
  <result property="groupId" column="GroupId" />
  <discriminator javaType="string" column="groupType">
    <case value="COMPANY" resultType="org.mybatis.entity.User">
      <association property="group" column="GroupId"
        select="selectCompany" />
    </case>
    <case value="SHOP" resultType="org.mybatis.entity.User">
      <association property="group" column="GroupId"
        select="selectShop" />
    </case>
  </discriminator>
</resultMap>

Regards,
Iwao

2017-03-03 14:54 GMT+09:00 rocbin <[hidden email]>:
I have four Class, the User group parent is the Company or Shop, the Class Company and Shop is implementation of IGroup.
The Entity Relationship(ER) Like this:



<resultMap id="userMap" type="org.mybatis.entity.User">
 
<id property="userId" column="UserId"/>
 
<result property="groupId" column="GroupId"/>
 
<association property="group">
   
<!-- how to coding?-->
 
</association>
</resultMap>


Is there any way, thank you!

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...