Uploaded image for project: 'Hibernate ORM'
  1. HHH-10959

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 5.2.1
    • Fix versions: 5.2.2
    • Components: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      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

        Attachments

        1. ConvertedDate.java
          0.1 kB
        2. ConvertedDateConverter.java
          1 kB
        3. ConvertedEntity.java
          0.3 kB
        4. JPAUnitTestCase.java
          2 kB

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: