Use same resultmap in a result ------------------------------ Key: IBATIS-597 URL: https://issues.apache.org/jira/browse/IBATIS-597 Project: iBatis for Java Issue Type: Wish Components: SQL Maps Environment: Not significant Reporter: Emilio Gutiérrez León
Hello. My question is about use of the one resultmap more than once in a result. Sample : <resultMap id="personMapping" class="Person"> ... <result property="name" column="NAME" /> <result property="personalAdress" resultMap="AdressMapping /> <result property="jobAdress" resultMap="AdressMapping /> </resultMap> <resultMap id="AdressMapping " class="Adress"> ... <result property="street" column="STREET" /> <result property="number" column="number" /> </resultMap> <select id="person_find" parameterClass="Person" resultMap="personMapping"> SELECT * FROM PERSON, ADRESS personal, ADRESS job WHERE PERSON_PERSONAL_ADDRESS_ID = personal.ADDRESS_ID AND PERSON_JOB_ADDRESS_ID = job.ADDRESS_ID AND PERSON_ID = #id# </select> <select id="adress_find" parameterClass="Adress" resultMap="adressMapping"> SELECT * FROM ADRESS <dynamic prepend="where"> <isNotNull property="id" prepend=" and ">ADRESS_ID = #id#</isNotNull> </dynamic> </select> When i use the select 'person_find', the result is composed by the data of the person, data of his personal adress and data of his job adress. When i see the result of the query in my person object, the personal adress and the job adress is the same because Ibatis can´t identify two mappings of the same table. In this sample, the 'adress_find' take one adress if 'id' is completed or all adresses if 'id' is null. This is necesary in my application. How can resolve this without duplicate 'address_find' ? Thanks -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.