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:[EMAIL PROTECTED] 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" callback="com.soe.freerealms.dao.ibatis.ByteArrayBigDecimalTypeHandler"/> So it will do a setBigDecimal instead: /*
* (non-Javadoc)
*
* @see com.ibatis.sqlmap.engine.type.TypeHandler#setParameter(java.sql.PreparedStatement,
* int, java.lang.Object, java.lang.String)
*/
public void setParameter(PreparedStatement ps, int i, Object parameter,
String jdbcType) throws SQLException {
BigDecimal decParam = new BigDecimal(new BigInteger(1,(byte[]) parameter));
ps.setBigDecimal(i, decParam);
} From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Andres, I guess I am confused as to what you are trying to do. Can you
give an example of the data? Nathan 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 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[]" =callback"com.soe.freerealms.dao.ibatis.ByteArrayBigDecimalTypeHandler" 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 |
- FW: specify typehandler for byte[] March, Andres
- Re: specify typehandler for byte[] Nathan Maves
- RE: specify typehandler for byte[] March, Andres
- RE: specify typehandler for byte[] March, Andres
- Re: specify typehandler for byte[] Nathan Maves
- RE: specify typehandler for byte[] March, Andres
- RE: specify typehandler for byte[] March, Andres