Menu

Pass parameterClass to complex properties

D Smith
2004-10-19
2013-04-11
  • D Smith

    D Smith - 2004-10-19

    I find myself needing to create seperate selects for complex properties when i need to use a different where predicate

    e.g.
    <resultMap id="person-rs-base" class="personEntity">
    <result property="name" column="name"/>
    <result property="id" column="id"/>
    </resultMap>

    <resultMap id="person-rs-oldKids" extends="person-rs-base">
    <result property="kids" column="id" select="getOldKids/>
    </resultMap>

    <resultMap id="person-rs-boys" extends="person-rs-base">
    <result property="kids" column="id" select="getBoys/>
    </resultMap>

    <select id="getOldKids" resultMap="person-rs-oldKids">
    .
    .
    WHERE AGE > 21
    </select>

    <select id="getBoys" resultMap="person-rs-boys">
    .
    .
    WHERE SEX = 'M'
    </select>

    I could avoid having to do all the parameterobject was passed to the complex property
    allowing me to embed a property to tell what where  predicate to use
    e.g.

    <isNotNull parameter="sexFlag">
      where ......
    </isNotNull>

    ------------------
    Ideal Situation

    map.put("person",person);
    map.put("ageFlag", new Boolean(true)");
    queryForObject("persons",map);

    <select id="person" paramClass="java.util.Map" resultMap="person-rs">
    SELECT ID,NAME FROM PERSON WHERE ID=#person.id#
    </select>

    <resultMap id="person-rs">
    <result property="name" column="name"/>
    <result property="id" column="id"/>
    <result property="kids" column="id" select="getKids/>
    </resultMap>

    <select id="getKids">
    select name, age, sex  from kids where P_ID = #person.id"
    <isNotNull parameter="sexFlag">
      where ......
    </isNotNull>
    </select>

     
    • Brandon Goodin

      Brandon Goodin - 2004-10-22

      THIS IS A USER SUPPORT QUESTION AND IS NOT RELATED TO THE DEVELOPMENT OF THE IBATIS FRAMEWORK. PLEASE POST ON THE USER SUPPORT FORUM IN THE FUTURE.

       
    • D Smith

      D Smith - 2004-10-22

      Feature Requests:
      http://sourceforge.net/forum/forum.php?forum_id=206694

      Unless this is already supported I believe this would fall under this category, or maybe update the ibatis.com support page..

       
    • Brandon Goodin

      Brandon Goodin - 2004-10-22

      Sorry, I was cleaning out some previous non-related postings as inappropriate and yours appeared as such. Your posting is difficult to understand and it appears you have made some mistakes in your coded example of the problem. I think I understand now what your are asking for.

      Is the problem that you can only pass a single value to the select for the complex property? Therefore. it limits you from having more than a single "where" criteria and thus requiring you to have multiple result maps to handle various selection scenarios?

      If yes, then we can add that to the feature request list. If no, then please take another stab at clarifying yourself and take the time to read your post for typos and code inaccuracies.

      Hope i got it right :)
      Brandon

       
      • D Smith

        D Smith - 2004-10-22

        Ok, I will fix up the example

         
    • D Smith

      D Smith - 2004-10-22

      errr, I did the same thing you did. I didn't fully read up your post.

      Yes, that is exactly what i'm asking for passing the all the parameters passed to the "parent" select to the "child" (complex property) select

       
    • D Smith

      D Smith - 2004-10-22

      And now I need a spell checker, its Friday....

      Yes, that is excatly what i'm asking for. That a "child" select recieves all the parameters a "parent" select recieves

       

Log in to post a comment.