We're updating the issue view to help you get more done. 

Methods in org.hibernate.query.Query should not return the deprecated org.hibernate.Query

Description

The object valued temporal setParameter variants have been deprecated starting with 5.2. That may have been an oversight that these are required to bind attribute converted values there.

I would not mind to moving to the typed variants, I'll just have to do the conversion myself.
However, the typed variants fail with a ClassCastException when there is an attribute converter in place, as it still tries to apply the converter on the value (which of course is not of the converted type).

Caused by: javax.persistence.PersistenceException: Error attempting to apply AttributeConverter
at org.hibernate.type.descriptor.converter.AttributeConverterSqlTypeDescriptorAdapter$1.bind(AttributeConverterSqlTypeDescriptorAdapter.java:84)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:277)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:272)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:53)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:628)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1950)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1903)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1881)
at org.hibernate.loader.Loader.scroll(Loader.java:2685)
at org.hibernate.loader.hql.QueryLoader.scroll(QueryLoader.java:571)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.scroll(QueryTranslatorImpl.java:423)
at org.hibernate.engine.query.spi.HQLQueryPlan.performScroll(HQLQueryPlan.java:350)
at org.hibernate.internal.SessionImpl.scroll(SessionImpl.java:1544)
at org.hibernate.query.internal.AbstractProducedQuery.doScroll(AbstractProducedQuery.java:1349)
at org.hibernate.query.internal.AbstractProducedQuery.scroll(AbstractProducedQuery.java:1338)
at org.hibernate.query.internal.AbstractProducedQuery.stream(AbstractProducedQuery.java:1355)
[...]
Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to org.joda.time.DateTime
at eu.agno3.runtime.db.orm.converters.DateTimeJPAConverter.convertToDatabaseColumn(DateTimeJPAConverter.java:1)
at org.hibernate.type.descriptor.converter.AttributeConverterSqlTypeDescriptorAdapter$1.bind(AttributeConverterSqlTypeDescriptorAdapter.java:78)
... 101 more

Environment

None

Status

Assignee

Andrea Boriero

Reporter

Moritz Bechler

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.1

Priority

Major