cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: convertHexToBytes from H2
Date Mon, 19 Nov 2012 08:19:08 GMT
BLOB most closely corresponds to byte[] in Java. While technically Cayenne can convert a BLOB
to a String, this will not be a safe conversion, as we can't be sure of the encoding, or even
if the BLOB corresponds to "text". To understand why, consider why Java has separate InputStream
and Reader interfaces. This is a very close analogy.

Your best bet is to map it to byte[] in Cayenne and convert it to String in your code as needed.

Andrus


On Nov 18, 2012, at 2:34 PM, emeka okafor <emeka_1978@yahoo.com> wrote:

> String -> CLOB is working
> String -> BLOB not so much.
> 
> 
> ________________________________
> From: emeka okafor <emeka_1978@yahoo.com>
> To: "user@cayenne.apache.org" <user@cayenne.apache.org> 
> Sent: Sunday, November 18, 2012 12:07 PM
> Subject: convertHexToBytes from H2
> 
> 
> 
>  Hello,
> I have an entity with an attribute "description" of type BLOB but is represented in java
as a java.lang.String. while trying to save that entity, I get this error:
> org.h2.jdbc.jdbcsqlexception hexadecimal string with odd number of characters 
> 
> Any Idea?


Mime
View raw message