ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McCORMICK, Paul" <Paul.McCORM...@doir.wa.gov.au>
Subject RE: ResultSet metadata
Date Fri, 08 Jul 2005 07:35:29 GMT

I've got a similar problem.  I have a immutable Quantity object that takes two arguments for
its constructor.  No of the Quantity properties can be populated using setter methods. I would
like to use a custom type handler to construct the object.  Doing reflection on the result
set will not always work because as there can be more that one Quantity objects per row.

Here is my idea how ibatis could be changed for this to work.
1) Allow multiple column names to be in the 'column' attribute of the result tag.   See below.
<resultMap ...>
        <result property="amountOne" column="amount1, currencyType1" typeHandler="QuantityTypeHandler"/>
        <result property="amountTwo" column="amount2, currencyType2" typeHandler="QuantityTypeHandler"/>

2) Add a method to give the TypeHandlerCallback access to the names of the column.
public interface TypeHandlerCallback {
        public String[] getColumnNames();

This would allow reflection on the result set using the column names.  I'm sure there are
more elegant ways to do this where ibatis would do the reflection.   I guess I can expect
someone to implement this in the next few days :)


-----Original Message-----
From: Ron Turner [mailto:raturne@shaw.ca]
Sent: Friday, 08 July 2005 4:28 AM
To: user-java@ibatis.apache.org
Subject: ResultSet metadata

Hi All,

I'm writing a custom type handler and want to get access to the meta data for the column in
context at the time the handler is invoked. I know that I can get access to the complete result
set using getter.getResultSet(), but how do I identify the particular column in which I'm
interested?  There doesn't appear to be a way to obtain the column's name from the ResultGetter
and I'm reluctant to use reflection to obtain this information...  Any thoughts?


"DISCLAIMER: This email, including any attachments, is intended only for use by the addressee(s)
and may contain confidential and/or personal information and may also be the subject of legal
privilege. If you are not the intended recipient, you must not disclose or use the information
contained in it. In this case, please let me know by return email, delete the message permanently
from your system and destroy any copies.

Before you take any action based upon advice and/or information contained in this email you
should carefully consider the advice and information and consider obtaining relevant independent

View raw message