I experienced some problems storing binary data into an Access database with hibernate using the HXTT Access JDBC driver.
First problem:
--------------
It is not possible to use the hibernate type 'blob' with the HXTT Access JDBC driver. Inserting some binary data into a blob field crahes with the following exception:
java.lang.UnsupportedOperationException:
Blob may not be manipulated from creating session
at org.hibernate.lob.BlobImpl.excep(BlobImpl.java:104)
at org.hibernate.lob.BlobImpl.getBytes(BlobImpl.java:50)
at com.hxtt.global.ac.g(Unknown Source)
at com.hxtt.sql.access.f.a(Unknown Source)
at com.hxtt.sql.access.j.a(Unknown Source)
at com.hxtt.sql.access.j.a(Unknown Source)
at com.hxtt.sql.access.a2.a(Unknown Source)
at com.hxtt.sql.w.a(Unknown Source)
at com.hxtt.sql.b0.for(Unknown Source)
at com.hxtt.sql.bu.int(Unknown Source)
at com.hxtt.sql.de.a(Unknown Source)
at com.hxtt.sql.bm.a(Unknown Source)
at com.hxtt.sql.ag.a(Unknown Source)
at com.hxtt.sql.dg.char(Unknown Source)
at com.hxtt.sql.dg.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
... 13 more
Although this Exception is thrown by hibernate, this is a JDBC driver problem. Because of this limitation, it is not possible to use HXTT Access in a JPA (Java Persistence API) environment, where a large amount of binary data needs to be stored (at least not in a database independent way; we need to support SQL Server, MySQL and Oracle as well).
Second problem:
---------------
As you might know, hibernate can automatically create all tables of a database for you when the hibernate session factory is beeing started. Creating a table for a Java class with an attriute of type 'byte[]' will always fail with the following error message if the hibernate type is 'binary', 'varbinary' or 'longvarbinary':
ERROR [SchemaUpdate] Unsuccessful:
create table MATERIAL_IMAGE (DISCRIMINATOR varchar(31) not null, id bigint not null, DESCRIPTION varchar(255) null, IMAGE_DATA varbinary null, primary key (id))
ERROR [SchemaUpdate] Syntax error: Stopped parse at null
The driver does not accept the keyword 'null' after 'IMAGE_DATA' varbinary. So it's not possible to let hibernate create your tables, if you data model uses one of the hibernate types 'binary', 'varbinary' or 'longvarbinary'.
Best regards
Aendy
|