You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "McCORMICK, Paul" <Pa...@doir.wa.gov.au> on 2005/05/18 05:32:26 UTC

Custom Type Handler on multiple columns

Is it possible to use more than one column in a custom type handler. 

<resultMap id="productResult" class="product" >
	<result property="productId" column="pid" />
      <result property="productType" column="code_type, code_value" typeHandler="ProductTypeHandler"/>
</resultMap>

<select id="getProductById" resultMap="productResult" parameterClass="int" >
	select pid, code_type, code_value
	from product
	where pid = #value#
</select>

public class ProductTypeHandler implements TypeHandlerCallback {

    public Object getResult(ResultGetter getter) throws SQLException {
        String codeType = ....
        String codeValue =  How do I get this value from result getter. 

        return new ProductType(codeType, codeValue);
    }
}



Paul McCormick
IT Consultant
DEPARTMENT OF INDUSTRY AND RESOURCES
100 Plain Street, East Perth, Western Australia 6004
Telephone: +61 8 922 23481, 0422 958 958
www.doir.wa.gov.au



"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 advice.

Re: Custom Type Handler on multiple columns

Posted by Gilles Bayon <ib...@gmail.com>.
You have the getResultSet() method on ResultGetter which return the
underlying ResultSet so you can access all the columns.

-Gilles