In implementing some auditing code I took the time to make serializable some of our domain objects that were lacking the marker interface. But now it appears that somewhere in hibernate it is assuming one or more persistent class associations are saved/retrieved as blobs when in fact they have their own mappings defined? I've gone through the mapping files and tried to verify that all associations (especially the many-to-[one|many]) have defined the class to use (based on the assumption that hibernate is seeing a serializable implementation and not inspecting further) and yet I am still running into this problem. It is possible I have missed some and I will continue to look for ambiguous associations but is that even likely the problem? Is this a bug in hibernate that has maybe been fixed? (I am using an older 3.0 or 3.1 series and do not have the time to vet the latest with our application).
the stack trace:
Code:
16:52:17,600 ERROR [[action]] Servlet.service() for servlet action threw exception
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at com.g1440.siteauthor.service.ModuleTypeService.findTypes(ModuleTypeService.java:50)
[snipped for brevity]
Caused by: java.sql.SQLException: Unable to convert between java.lang.Integer and BINARY.
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:558)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getBytes(JtdsResultSet.java:714)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getBytes(JtdsResultSet.java:988)
at org.jboss.resource.adapter.jdbc.WrappedResultSet.getBytes(WrappedResultSet.java:238)
at org.hibernate.type.BinaryType.get(BinaryType.java:64)
at org.hibernate.type.SerializableType.get(SerializableType.java:34)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:759)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:292)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
the mapping:
Code:
<class name="com.g1440.siteauthor.data.ModuleType" table="[ModuleType]">
<id name="id" column="moduleTypeID">
<generator class="identity" />
</id>
<property name="name" />
<property name="pluralName" />
<property name="hasPublishDate" />
<property name="createdBy" />
<property name="createDate" type="timestamp" />
<property name="lastUpdatedBy" />
<property name="lastUpdateDate" type="timestamp" />
</class>
offending code (as per stack trace):
Code:
public static List findTypes(ModuleType example) {
log.debug("Searching module types");
if (example == null) {
throw new IllegalArgumentException();
}
Session session = HibernateUtil.getSession();
return session.createCriteria(ModuleType.class) // <-- this is ModuleTypeService.java line 50
.add(Example.create(example))
.addOrder(Order.asc("name"))
.list();
}
Any help would be appreciated, thanks.