For some ungawdly reason, in one of my many objects, Hibernate loads something that looks like some "blob reference" instead of the database column content.
When Hibernate calls my object InstDataSource.setValue(String value) method, the value is:
"[B@109506a" (or some other address value), instead of the data in the database (even MySQL Front can show the data right).
When I change the database column declaration from "TEXT" to "VARCHAR(255)", Hibernate loads the right values.
I suspect there is some sensitivity to "something" in the mapping file, but I am using the same property/column description in many other cases, where it works just fine.
The problem applies to columns "Value" and "Words", both of which are sql-type="TEXT". I can't find anything like "[B@" in Hibernate source, but tracking the setValue() in the debugger shows the value "[B@109506a" at least 5 levels deep down the Hibernate code.
Hibernate version:
3.0
MySQL driver:
mysql-connector-java-3.1.10-bin.jar
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.recordfusion.gen.model.county.InstDataSource" table="instdatasource" lazy="false">
<id name="Id" type="java.lang.Integer">
<column name="Id" scale="11" precision="0" not-null="false" unique="true" sql-type="int" />
<generator class="native" />
</id>
<version name="Version" type="integer" column="Version"/>
<property name="instDataId" type="java.lang.Integer">
<column name="InstDataId" not-null="false" sql-type="int" />
</property>
<property name="statusDB" type="java.lang.String">
<column name="Status" not-null="false" sql-type="varchar" />
</property>
<property name="value" type="java.lang.String">
<column name="Value" not-null="false" sql-type="TEXT" />
</property>
<property name="wordsDB" type="java.lang.String">
<column name="Words" not-null="false" sql-type="TEXT" />
</property>
<property name="creationDate" type="java.util.Date">
<column name="CreationDate" scale="19" precision="0" not-null="false" sql-type="datetime" />
</property>
<property name="updateDate" type="java.util.Date">
<column name="UpdateDate" scale="19" precision="0" not-null="false" sql-type="datetime" />
</property>
</class>
</hibernate-mapping>
Database Schema:
CREATE TABLE `instdatasource` (
`Id` int(11) NOT NULL auto_increment,
`Version` int(11) NOT NULL default '0',
`InstDataId` int(11) default NULL,
`Status` varchar(16) default NULL,
`Value` text collate utf8_bin,
`Words` text collate utf8_bin,
`CreationDate` datetime default NULL,
`UpdateDate` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`Id`),
KEY `InstDataId` (`InstDataId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Instrument data (field) raw data form';
Code between sessionFactory.openSession() and session.close():
Query qsrc = ses.createQuery("select src from InstData data, InstDataSource src " +
" where data.instrument = :inst and src.instDataId = data.id ");
qsrc.setEntity("inst", inst);
// qsrc.setInteger("inst", inst.getId());
qsrc.setMaxResults(1024);
List<InstDataSource> srcs = qsrc.list();
Full stack trace of any exception that occurs:
Name and version of the database you are using:
MySQL 5.0 build 17 (the problem is the same in MySQL 5.0 beta)
The generated SQL (show_sql=true):
Hibernate: select instdataso1_.Id as Id, instdataso1_.Version as Version20_, instdataso1_.InstDataId as InstDataId20_, instdataso1_.Status as Status20_, instdataso1_.Value as Value20_, instdataso1_.Words as Words20_, instdataso1_.CreationDate as Creation7_20_, instdataso1_.UpdateDate as UpdateDate20_ from instdata instdata0_, instdatasource instdataso1_ where instdata0_.InstrId=? and instdataso1_.InstDataId=instdata0_.Id limit ?
Debug level Hibernate log excerpt:
|