lubosp wrote:
Hi,
I am using Hibernate with Hsqldb as embedded (in process) DB engine in my application. I tried to add support for Derby (now derby.apache.org).
It works OK in server/client mode, but it fails in embedded mode with error:
2006.04.26-11:14:42 [http-8080-Processor24] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 20000, SQLState: 22005
2006.04.26-11:14:42 [http-8080-Processor24] ERROR org.hibernate.util.JDBCExceptionReporter - An attempt was made to get a data value of type 'BLOB' from a data value of type 'VARBINARY'.
2006.04.26-11:14:42 [http-8080-Processor24] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
Note, that I store some Java serialized classes in DB, that is why I use BLOB.
I use Hibernate dialect org.hibernate.dialect.DerbyDialect, JDBC driver org.apache.derby.jdbc.EmbeddedDriver.
I use Hibernate 3.1.
Anybody has some experience or inside for this problem?
Hello all! I'm brand new to hibernate. Sadly I ran into the very same difficulty described above chiefly a problem with serializing BLOBs under Derby embedded. Although its a relatively ancient post, there didn't seem to be any response to this question so after searching the forums, I decided to try to build and debug hibernate in a layman's attempt to charactierize the problem. I think I at least have a clue as to where the problem is occurring although given my lack of experience here I offer my findings up for illumination, not as definitive reasoning.
I have a class that is defined something like:
@Entity
@Table(name="FOO")
public class Foo implements Serializable {
@Id
@Column(name="MyId", length=64)
private String myid;
...
@Column(name="CURRENT_CONFIG", columnDefinition="BLOB")
private MyConfigurationObject config;
etc...
}
What I'm seeing is that if the value of config == null, I wind up in AbstractBynaryType.sqlType which simply does a return Types.VARBINARY. Shortly thereafter I fail with the expection noted in the original post. The what I believe to be relevant, call sequence during the commit is AbstractEntityPersistence.insert() -> AbstractEntityPersistence.dehydrate() (love that name btw) -> which seems to loop through the values and calls NullableType.nullSafeSet() which ultimate makes its way to return the VARBINARY type for a column which has been declared as a BLOB. Indeed, in my test program if I assign a non-null value to config, all is fine.
Given a nearly complete lack of familiarity with some of the subtleties involved here, I thought I would resurrect the thread, offer my observations and see if anyone could offer a solution or some advice on how to work around this as I have to be able to store some null values on BLOB type columns and embedded Derby is pretty much of a requirement.
Thx!
=Ron=