You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Farnea Massimiliano <ma...@atscom.it> on 2003/03/26 10:23:41 UTC
Problem with storing in a LONG RAW field
Hi,
I need to store a String that could be very long, so I decided to map it on
a LONG RAW Oracle field.
The Java bean attribute is a String and is named 'riassunto'.
The Oracle table field is a LONG RAW name TXT_RIASSUNTO
I used the following mappings:
1)
I put in the repository.xml the mapping:
...
<field-descriptor
name="riassunto"
column="TXT_RIASSUNTO"
jdbc-type="LONGVARBINARY"
conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFiel
dConversion"
/>
...
when I try to persist/update my bean I got the exception:
java.lang.NoSuchFieldException
at java.lang.Class.getField0(Native Method)
at java.lang.Class.getDeclaredField(Class.java:1113)
.......
and I found some bytes stored in the Oracle field that seems to be
meaningless.
2) without the conversion, I got a:
java.sql.SQLException: java.lang.ClassCastException: java.lang.String
3) using an attribute type byte[] instead of String and the mapping:
<field-descriptor
name="riassunto"
column="TXT_RIASSUNTO"
jdbc-type="LONGVARBINARY"
conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFiel
dConversion"
/>
I got,
java.lang.NoSuchFieldException
at java.lang.Class.getField0(Native Method)
at java.lang.Class.getDeclaredField(Class.java:1113)
4) Finally storing a byte[] without the conversion I got:
java.lang.NoSuchFieldException
at java.lang.Class.getField0(Native Method)
at java.lang.Class.getDeclaredField(Class.java:1113)
and I found the attribute value stored in HEX format !
How can I do a clean storing, without errors and exceptions?
Where can I find working examples about storing in LONG RAW?
Thanks in advance,
Massimiliano Farnea