ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "March, Andres" <ama...@soe.sony.com>
Subject FW: specify typehandler for byte[]
Date Thu, 19 Jan 2006 18:45:44 GMT
Got no closure on this issue on the users list.  I do believe it is a
bug but I couldn't locate it in the source myself, since I'm not
familiar with it.  If you guys concur, I can open a JIRA issue.



From: March, Andres [mailto:amarch@soe.sony.com] 
Sent: Monday, January 09, 2006 9:30 AM
To: user-java@ibatis.apache.org
Subject: RE: specify typehandler for byte[]


I want to emphasize that this works when I specify the handler per
column in the sqlmap parameter map because I don't need to specify the
javaType there.  But I want to specify it globally, so I don't have to
create parameterMaps and typeHandler declarations for every column.


My class has a property like this:


Private ds byte[ ]


The db tables are like this:


CREATE TABLE bugs.x86_seg_reg


  id int8 NOT NULL DEFAULT nextval('x86_seg_reg_id_seq'::regclass),

  ds numeric(16) NOT NULL,

  es numeric(16) NOT NULL,

  fs numeric(16) NOT NULL,

  gs numeric(16) NOT NULL,

  CONSTRAINT x86_seg_reg_pkey PRIMARY KEY (id)



The sql created from the default type handler does setBytes() but
Postgres interprets that as a bytea column type.  So I created my own
type handler:

<typeHandler javaType="byte[]" jdbcType="NUMERIC"


So it will do a setBigDecimal instead:



             * (non-Javadoc)


             * @see

             *      int, java.lang.Object, java.lang.String)


            public void setParameter(PreparedStatement ps, int i, Object

                                    String jdbcType) throws SQLException

                        BigDecimal decParam = new BigDecimal(new
BigInteger(1,(byte[]) parameter));

                        ps.setBigDecimal(i, decParam);






From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM] 
Sent: Sunday, January 08, 2006 6:50 PM
To: user-java@ibatis.apache.org
Subject: Re: specify typehandler for byte[]




I guess I am confused as to what you are trying to do.  Can you give an
example of the data?





On Jan 6, 2006, at 7:22 PM, March, Andres wrote:


I'm trying to write the bytes to a numeric column not a binary one.  The
default one uses setBytes().  I need to do setBigDecimal().



From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM] 
Sent: Friday, January 06, 2006 6:19 PM
To: user-java@ibatis.apache.org
Subject: Re: specify typehandler for byte[]


why is the default not good enough for you?


On Jan 6, 2006, at 6:51 PM, March, Andres wrote:

Well, I learned something new today - the internal representation of
class names.  This mapping does not fail like before:


typeHandler =jdbcType"NUMERIC" =<javaType"byte[]"

But I get an error because iBatis is doing a class.forName() on the
javaType attribute.  Is there any way to do this mapping?


Platform - Apps Engineering

desk: 858.577.3373



View raw message