When I define a resultMap for an object, I'd like to do that once and reuse it everywhere in my application. The problem I have is that for some queries the column names are not the same and so I wind up having to make another resultMap using the column-alias names.
This comes up a lot when I use joins. It came up again and I'd really like to hear from the community if there is a solution. I have "iBatis in Action", been looking thru the docs, and google... am I missing something? Take a look at my example below and please suggest, Thanks in advance. In the example, I have a message object that contains two contacts (sender and recipient); this means two joins and aliases for the columns. It would be cool to somehow reuse a single result map passing in a "prefix". <resultMap id="senderResultMap" class="contact"> <result property="id" column="sid"/> <result property="name" column="sname"/> <result property="emailAddress" column="semailaddress"/> <result property="phoneNumber" column="sphonenumber"/> </resultMap> <resultMap id="recipientResultMap" class="contact"> <result property="id" column="rid"/> <result property="name" column="rname"/> <result property="emailAddress" column="remailaddress"/> <result property="phoneNumber" column="rphonenumber"/> </resultMap> <resultMap id="messageResultMap" class="message"> <result property="id" column="id"/> <result property="sender" resultMap="Messages.senderResultMap"/> <result property="recipient" resultMap="Messages.recipientResultMap"/> <result property="subject" column="subject"/> <result property="content" column="content"/> </resultMap> <select id="findAll" resultMap="messageResultMap"> select id, sender.id sid, sender.name sname, sender.emailaddress semailaddress, sender.phonenumber sphonenumber, recipient.id rid, recipient.name rname, recipient.emailaddress remailaddress, recipient.phonenumber rphonenumber, subject, content from messages m left join contacts sender on m.sender = sender.id left join contacts recipient on m.recipient = recipient.id </select> -- View this message in context: http://www.nabble.com/Cant-reuse-resultMaps-when-I-have-column-aliases-tp20980742p20980742.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com.