I am using Hibernate version:3.1.3 with Mysql 4.1.11 and my test classes are using: hsqldb 1.8.0.1
I try to get a list of Data (abstract superclass of BinaryData and XMLData) using the following code:
Code:
public List<Data> get(List<DataIdentifier> dataIdentifiers) throws DaoException {
List <Data>dataList = new ArrayList<Data>();
try {
Criteria criteria = getSession().createCriteria(Data.class);
criteria.add( Expression.in("dataIdentifier", dataIdentifiers) );
dataList = criteria.list();
} catch (Exception e) {
log.error(e,e);
throw new DaoException("Get failed ", e);
}
return dataList;
}
With mysql I don't get any results. Here is the query generated by Hibernate:
With hsqldb I got an exception. If needed I can post the exception. The query is quite long so I left it out.
Here are my mapping files:
Code:
<?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 package="nl.tesis">
<class name="Data" table="data">
<composite-id name="dataIdentifier" class="DataIdentifier">
<key-property name="userId" length="200"/>
<key-property name="eaGroupId"/>
<key-property name="dossierId"/>
<key-property name="sectionId"/>
</composite-id>
<property name="created"/>
<property name="createdByUserId"/>
<property name="lastModified"/>
<property name="lastModifiedByUserId"/>
</class>
</hibernate-mapping>
Code:
<?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 package="nl.tesis">
<joined-subclass name="BinaryData" table="binarydata" extends="Data">
<key>
<column name="userId" />
<column name="eaGroupId" />
<column name="dossierId" />
<column name="sectionId" />
</key>
<property name="mimeType" />
<property name="originalFilename" />
<property name="data" length="10485760"/> <!-- 1024 * 1024 * 10 = 10Mb-->
</joined-subclass>
</hibernate-mapping>
The mapping file for XMLData is almost the same as BinrayData. There are 2 different properties.
The generated SQL (show_sql=true):