IllegalArgumentException when binding arbitrarily typed data to a query where a custom property type is expected in Hibernate

Solution Verified - Updated -


  • A custom type (e.g. EmployeeState) is declared for an entity property.
  • The entity property is annotated with a user type handler implementation (e.g. EmployeeStateType) which supplies nullSafeSet(...), nullSafeGet(...), etc.
  • The nullSafeSet(...) method is implemented to handle types other than the declared entity property type (e.g. String as well as the required EmployeeState type).
  • When binding a String parameter to a named query in place of the custom type (i.e. EmployeeState) an exception is raised:

    ... java.lang.IllegalArgumentException: Parameter value [Active] did not match expected type [support.hibernate.entity.EmployeeState (n/a)]
        at org.hibernate.query.spi.QueryParameterBindingValidator.validate(
        at org.hibernate.query.spi.QueryParameterBindingValidator.validate(
        at org.hibernate.query.internal.QueryParameterBindingImpl.validate(
        at org.hibernate.query.internal.QueryParameterBindingImpl.setBindValue(
        at org.hibernate.query.internal.AbstractProducedQuery.setParameter(
        at org.hibernate.query.internal.AbstractProducedQuery.setParameter(
  • In Hibernate 3, no exception was raised.


  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Hibernate 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In