hibernate - JPA "cannot be cast to java.sql.Blob" -


i'm using jpa2 hibernate 3.6.1. , derby database , used following annotation blob:

@column(length = integer.max_value) @lob long[] bucket; 

hibernate creates correct blob column if try save entity following exception:

java.lang.classcastexception: [j cannot cast java.sql.blob

why , how can make work?

if annotate without @lob "varchar bit data" column can contain 32m.

you need map property byte[], not long[].

the documentation says

@lob indicates property should persisted in blob or clob depending on property type: java.sql.clob, character[], char[] , java.lang.string persisted in clob. java.sql.blob, byte[], byte[] , serializable type persisted in blob.

if property type implements java.io.serializable , not basic type, , if property not annotated @lob, hibernate serializable type used.

if want persist array, you'll need build custom user type transform data type. can find example here http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html#d0e2794


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -