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 Jonathan Alvarsson <jo...@gmail.com> on 2007/09/28 13:56:09 UTC

Mapping HSQLDB's binary using iBatis

I am trying persist a serializable object to hsqldb's binary datatype. I am
currently building a byte[] but obviously there is no iBatis standard type
handler for this operation because I get the following errorwhen trying to
persist:

org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad
SQL grammar []; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in sqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the Structure.insertWithoutLibrary-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: Wrong data type: java.io.IOException:
hexadecimal string contains non hex character in statement [         INSERT
INTO Structure (   id,     baseObject, smiles,     fingerPrintString,
molecule       )                        VALUES (
'07bdad55-1433-4b12-8446-aa7d0fe644f9',
'07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
'0000000000000000000000000000000000000000000000000000000000000000', '[
B@1107304' );     ]
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in sqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the Structure.insertWithoutLibrary-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: Wrong data type: java.io.IOException:
hexadecimal string contains non hex character in statement [         INSERT
INTO Structure (   id,     baseObject, smiles,     fingerPrintString,
molecule       )                        VALUES (
'07bdad55-1433-4b12-8446-aa7d0fe644f9',
'07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
'0000000000000000000000000000000000000000000000000000000000000000', '[
B@1107304' );     ]

How can I make this work?

-- 
// Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jonathan Alvarsson <jo...@gmail.com>.
On 9/28/07, Yee, Richard K CTR DMDC <Ri...@osd.pentagon.mil>
wrote:
>
> What does the code look like that you are using to call the
> sqlMap.insert() with? It looks like you are passing in a string for the
> byte[]


I changed approach and now persists a String serialisation of the object
instead. But thanks anyway for your time!

-- 
// Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
I'm inserting images into MS Sql (table field type is image i.e.
variable-length binary data) without problems with no special configuration.
I have an Image class with two properties
       String imageID
       byte[] imageBytes
and the insert looks like

<insert id='insertImage' parameterClass='Image'>
         insert into images (ImageID,image)
                 values ( #imageID#,#imageBytes#)
</insert>


Maybe you should try different DB engine to identify whether it's DB/jdbc
driver issue or your app/configuration problem?





On Tue, May 27, 2008 at 6:32 PM, Jonathan Alvarsson <
jonathan.alvarsson@gmail.com> wrote:

> Okey this was a really long time ago but attempt to circumvent this is not
> working. I really need the BINARY data type in the database because I need
> to perform bitwise and during a query (btw: would you do that in a stored
> procedure?). I am using HSQLDB for the moment and I see that they use byte[]
> for internal representation of a binary so I thought I would try that but
> that was of course not the way to go. How do I insert to a binary column
> using iBatis? It must be possible to do somehow right?
>
> On Fri, Sep 28, 2007 at 5:35 PM, Yee, Richard K CTR DMDC <
> Richard.Yee.ctr@osd.pentagon.mil> wrote:
>
>> What does the code look like that you are using to call the
>> sqlMap.insert() with? It looks like you are passing in a string for the
>> byte[]
>>
>> -Richard
>>
>> -----Original Message-----
>> From: Jonathan Alvarsson [mailto:jonathan.alvarsson@gmail.com]
>> Sent: Friday, September 28, 2007 4:56 AM
>> To: user-java@ibatis.apache.org
>> Subject: Mapping HSQLDB's binary using iBatis
>>
>> I am trying persist a serializable object to hsqldb's binary datatype. I
>> am currently building a byte[] but obviously there is no iBatis standard
>> type handler for this operation because I get the following errorwhen
>> trying to persist:
>>
>>
>> org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation;
>> bad SQL grammar []; nested exception is
>> com.ibatis.common.jdbc.exception.NestedSQLException:
>> --- The error occurred in sqlMap.xml.
>> --- The error occurred while applying a parameter map.
>> --- Check the Structure.insertWithoutLibrary-InlineParameterMap.
>> --- Check the statement (update failed).
>> --- Cause: java.sql.SQLException : Wrong data type: java.io.IOException:
>> hexadecimal string contains non hex character in statement [
>> INSERT INTO Structure (   id,     baseObject, smiles,
>> fingerPrintString,     molecule       )                        VALUES (
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
>> '0000000000000000000000000000000000000000000000000000000000000000', '[
>> B@1107304' );     ]
>> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
>> --- The error occurred in sqlMap.xml.
>> --- The error occurred while applying a parameter map.
>> --- Check the Structure.insertWithoutLibrary-InlineParameterMap .
>> --- Check the statement (update failed).
>> --- Cause: java.sql.SQLException: Wrong data type: java.io.IOException:
>> hexadecimal string contains non hex character in statement [
>> INSERT INTO Structure (   id,     baseObject, smiles,
>> fingerPrintString,     molecule       )                        VALUES (
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
>> '0000000000000000000000000000000000000000000000000000000000000000', '[
>> B@1107304' );     ]
>>
>>
>> How can I make this work?
>>
>> --
>> // Jonathan
>>
>
>
>
> --
> // Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jeff Butler <je...@gmail.com>.
This is an inline parameter mapping:

<insert id="foo" parameterClass="Bar">
  insert into foo (binaryField) values(#binaryField:BINARY#)
</insert>

Setting the JDBC type to BINARY here will help if you ever need to set the
field to NULL.  If it won't ever be NULL, then you don't need the JDBC type
(but it doesn't hurt to add it anyway).

Jeff Butler




On Tue, May 27, 2008 at 3:10 PM, Jonathan Alvarsson <
jonathan.alvarsson@gmail.com> wrote:

>
> On Tue, May 27, 2008 at 6:32 PM, Jeff Butler <je...@gmail.com>
> wrote:
>
>> Inline parameter mappings only - and only for NULL capable fields!  I
>> detest the XML parameter maps!  :)
>>
>
> huh which syntax would that be? I am not great at the lingo I feel... :)
>
> --
> // Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jonathan Alvarsson <jo...@gmail.com>.
On Tue, May 27, 2008 at 6:32 PM, Jeff Butler <je...@gmail.com> wrote:

> Inline parameter mappings only - and only for NULL capable fields!  I
> detest the XML parameter maps!  :)
>

huh which syntax would that be? I am not great at the lingo I feel... :)

-- 
// Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jeff Butler <je...@gmail.com>.
Inline parameter mappings only - and only for NULL capable fields!  I detest
the XML parameter maps!  :)

Jeff Butler

On Tue, May 27, 2008 at 11:04 AM, Jonathan Alvarsson <
jonathan.alvarsson@gmail.com> wrote:

> On Tue, May 27, 2008 at 5:11 PM, Jeff Butler <je...@gmail.com>
> wrote:
>
>> I have tests working fine with the HSQLDB binary type:
>>
>> 1. Use a byte[] for the property.
>> 2. Set jdbcType to "BINARY" in your parameter and result mappings
>>
>> Jeff Butler
>>
>
> LOL, paramater mappings? :)
>
> I wrote my first just now. It seems to work. Thanks
> (I will mail again if I run into more problems)  :)
>
> --
> // Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jonathan Alvarsson <jo...@gmail.com>.
On Tue, May 27, 2008 at 5:11 PM, Jeff Butler <je...@gmail.com> wrote:

> I have tests working fine with the HSQLDB binary type:
>
> 1. Use a byte[] for the property.
> 2. Set jdbcType to "BINARY" in your parameter and result mappings
>
> Jeff Butler
>

LOL, paramater mappings? :)

I wrote my first just now. It seems to work. Thanks
(I will mail again if I run into more problems)  :)

-- 
// Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jeff Butler <je...@gmail.com>.
I have tests working fine with the HSQLDB binary type:

1. Use a byte[] for the property.
2. Set jdbcType to "BINARY" in your parameter and result mappings

Jeff Butler


On Tue, May 27, 2008 at 9:32 AM, Jonathan Alvarsson <
jonathan.alvarsson@gmail.com> wrote:

> Okey this was a really long time ago but attempt to circumvent this is not
> working. I really need the BINARY data type in the database because I need
> to perform bitwise and during a query (btw: would you do that in a stored
> procedure?). I am using HSQLDB for the moment and I see that they use byte[]
> for internal representation of a binary so I thought I would try that but
> that was of course not the way to go. How do I insert to a binary column
> using iBatis? It must be possible to do somehow right?
>
>
> On Fri, Sep 28, 2007 at 5:35 PM, Yee, Richard K CTR DMDC <
> Richard.Yee.ctr@osd.pentagon.mil> wrote:
>
>> What does the code look like that you are using to call the
>> sqlMap.insert() with? It looks like you are passing in a string for the
>> byte[]
>>
>> -Richard
>>
>> -----Original Message-----
>> From: Jonathan Alvarsson [mailto:jonathan.alvarsson@gmail.com]
>> Sent: Friday, September 28, 2007 4:56 AM
>> To: user-java@ibatis.apache.org
>> Subject: Mapping HSQLDB's binary using iBatis
>>
>> I am trying persist a serializable object to hsqldb's binary datatype. I
>> am currently building a byte[] but obviously there is no iBatis standard
>> type handler for this operation because I get the following errorwhen
>> trying to persist:
>>
>>
>> org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation;
>> bad SQL grammar []; nested exception is
>> com.ibatis.common.jdbc.exception.NestedSQLException:
>> --- The error occurred in sqlMap.xml.
>> --- The error occurred while applying a parameter map.
>> --- Check the Structure.insertWithoutLibrary-InlineParameterMap.
>> --- Check the statement (update failed).
>> --- Cause: java.sql.SQLException : Wrong data type: java.io.IOException:
>> hexadecimal string contains non hex character in statement [
>> INSERT INTO Structure (   id,     baseObject, smiles,
>> fingerPrintString,     molecule       )                        VALUES (
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
>> '0000000000000000000000000000000000000000000000000000000000000000', '[
>> B@1107304' );     ]
>> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
>> --- The error occurred in sqlMap.xml.
>> --- The error occurred while applying a parameter map.
>> --- Check the Structure.insertWithoutLibrary-InlineParameterMap .
>> --- Check the statement (update failed).
>> --- Cause: java.sql.SQLException: Wrong data type: java.io.IOException:
>> hexadecimal string contains non hex character in statement [
>> INSERT INTO Structure (   id,     baseObject, smiles,
>> fingerPrintString,     molecule       )                        VALUES (
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',
>> '07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
>> '0000000000000000000000000000000000000000000000000000000000000000', '[
>> B@1107304' );     ]
>>
>>
>> How can I make this work?
>>
>> --
>> // Jonathan
>>
>
>
>
> --
> // Jonathan

Re: Mapping HSQLDB's binary using iBatis

Posted by Jonathan Alvarsson <jo...@gmail.com>.
Okey this was a really long time ago but attempt to circumvent this is not
working. I really need the BINARY data type in the database because I need
to perform bitwise and during a query (btw: would you do that in a stored
procedure?). I am using HSQLDB for the moment and I see that they use byte[]
for internal representation of a binary so I thought I would try that but
that was of course not the way to go. How do I insert to a binary column
using iBatis? It must be possible to do somehow right?

On Fri, Sep 28, 2007 at 5:35 PM, Yee, Richard K CTR DMDC <
Richard.Yee.ctr@osd.pentagon.mil> wrote:

> What does the code look like that you are using to call the
> sqlMap.insert() with? It looks like you are passing in a string for the
> byte[]
>
> -Richard
>
> -----Original Message-----
> From: Jonathan Alvarsson [mailto:jonathan.alvarsson@gmail.com]
> Sent: Friday, September 28, 2007 4:56 AM
> To: user-java@ibatis.apache.org
> Subject: Mapping HSQLDB's binary using iBatis
>
> I am trying persist a serializable object to hsqldb's binary datatype. I
> am currently building a byte[] but obviously there is no iBatis standard
> type handler for this operation because I get the following errorwhen
> trying to persist:
>
>
> org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation;
> bad SQL grammar []; nested exception is
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in sqlMap.xml.
> --- The error occurred while applying a parameter map.
> --- Check the Structure.insertWithoutLibrary-InlineParameterMap.
> --- Check the statement (update failed).
> --- Cause: java.sql.SQLException : Wrong data type: java.io.IOException:
> hexadecimal string contains non hex character in statement [
> INSERT INTO Structure (   id,     baseObject, smiles,
> fingerPrintString,     molecule       )                        VALUES (
> '07bdad55-1433-4b12-8446-aa7d0fe644f9',
> '07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
> '0000000000000000000000000000000000000000000000000000000000000000', '[
> B@1107304' );     ]
> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in sqlMap.xml.
> --- The error occurred while applying a parameter map.
> --- Check the Structure.insertWithoutLibrary-InlineParameterMap .
> --- Check the statement (update failed).
> --- Cause: java.sql.SQLException: Wrong data type: java.io.IOException:
> hexadecimal string contains non hex character in statement [
> INSERT INTO Structure (   id,     baseObject, smiles,
> fingerPrintString,     molecule       )                        VALUES (
> '07bdad55-1433-4b12-8446-aa7d0fe644f9',
> '07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
> '0000000000000000000000000000000000000000000000000000000000000000', '[
> B@1107304' );     ]
>
>
> How can I make this work?
>
> --
> // Jonathan
>



-- 
// Jonathan

RE: Mapping HSQLDB's binary using iBatis

Posted by "Yee, Richard K CTR DMDC" <Ri...@osd.pentagon.mil>.
What does the code look like that you are using to call the
sqlMap.insert() with? It looks like you are passing in a string for the
byte[]

-Richard

-----Original Message-----
From: Jonathan Alvarsson [mailto:jonathan.alvarsson@gmail.com] 
Sent: Friday, September 28, 2007 4:56 AM
To: user-java@ibatis.apache.org
Subject: Mapping HSQLDB's binary using iBatis

I am trying persist a serializable object to hsqldb's binary datatype. I
am currently building a byte[] but obviously there is no iBatis standard
type handler for this operation because I get the following errorwhen
trying to persist: 


org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation;
bad SQL grammar []; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in sqlMap.xml.  
--- The error occurred while applying a parameter map.  
--- Check the Structure.insertWithoutLibrary-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException : Wrong data type: java.io.IOException:
hexadecimal string contains non hex character in statement [
INSERT INTO Structure (   id,     baseObject, smiles,
fingerPrintString,     molecule       )                        VALUES (
'07bdad55-1433-4b12-8446-aa7d0fe644f9',
'07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
'0000000000000000000000000000000000000000000000000000000000000000', '[
B@1107304' );     ]
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in sqlMap.xml.  
--- The error occurred while applying a parameter map.  
--- Check the Structure.insertWithoutLibrary-InlineParameterMap .  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: Wrong data type: java.io.IOException:
hexadecimal string contains non hex character in statement [
INSERT INTO Structure (   id,     baseObject, smiles,
fingerPrintString,     molecule       )                        VALUES (
'07bdad55-1433-4b12-8446-aa7d0fe644f9',
'07bdad55-1433-4b12-8446-aa7d0fe644f9',     '',
'0000000000000000000000000000000000000000000000000000000000000000', '[
B@1107304' );     ]


How can I make this work?

--
// Jonathan