Share

iBATIS Database Layer

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

How to set dynamic table name in xml file?

You are viewing a single message from this topic. View all messages.

  1. 2006-08-25 05:32:37 UTC
    hey.
    help me, please....
    single object,set dynamic table name is very easy,I can use $tableName$.
    if object is complex,how i can set dynamic table name in child object.like this:
    <typeAlias alias="A" type="A"/>
    <typeAlias alias="B" type="B"/>
    <resultMap id="RA" class="A">
    <result property="id" column="PLUGIN_ID" javaType="java.lang.Long"/>
    <result property="name" column="NAME" javaType="java.lang.String"/>
    <result property="b" column="PLUGIN_ID" select="queryB"/>
    </resultMap>
    <resultMap id="RB" class="B">
    <result property="id" column="ROLE_ID" javaType="java.lang.Long"/>
    <result property="code" column="CODE" javaType="java.lang.String"/>
    </resultMap>
    <select id="queryA"
    parameterClass="ParamPlugin"
    resultMap="ResultPluginModel">
    <![CDATA[
    select *
    from $tableName$
    ]]>
    </select>
    <select id="queryB"
    parameterClass="int"
    resultMap="B">
    <![CDATA[
    select *
    from $tableName$ where PLUGIN_ID=#value#
    ]]>

    if this code has't $tableName$,it's right.but if has $tableName$.how i set parameterClass in id="queryB".
    if set parameterClass="int" ,then $tableName$ can't get.but set parameterClass="B".parent object's value
    can't get...
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.