We are trying to upgrade to Java 8, meaning that we will need Spring 4, and to upgrade to spring 4 we need to migrate to Hibernate 4.3 (We are currently on 3.4).
During the upgrade, we concluded that there are some changes within the QueryImpl
implementation (hibernate).
Within the setParameter(String name, Object value)
, there is a new typecheck added (via the bindValue
method call that is done in the new hibernate implementation).
This is causing our repository implementation to break, because all our entities have a custom type as identifier. These custom types all extend a class named AbstractEntityId
, containing the actual ID as a long
.
The problem is that in all our queries, we pass the id as a long
. Before the upgrade, this never was a problem. But due to the hibernate changes we now get an IllegalArgumentException
because of the new typecheck that was added.
Is there a way to work around this problem, without needing to change our queries (and thus that we can keep passing long
's). If not, what would be the most efficient solution to deal with this problem?
Sidenote: the check that was added in the new QueryImpl implementation of Hibernate:
if ( Collection.class.isInstance( bind ) && ! Collection.class.isAssignableFrom( parameterType ) ) {
Old implementation: hibernate-entitymanager-3.4.0.GA-jboss : org.hibernate.ejb.QueryImpl.class
New implementation: hibernate-entitymanager-4.3.11.Final : org.hibernate.jpa.internal.QueryImpl.class