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

JPA CriteriaUpdate - NullLiteral causes IllegalArgumentException: Could not convert java type to Hibernate type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.2.1, 5.2.2, 5.1.1, 5.0.11, 5.1.2, 5.2.3
    • Fix Version/s: 5.2.4, 5.1.3, 5.0.12
    • Component/s: None
    • Labels:
    • Environment:
      Java 1.8.0_92
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

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

      Description

      Executing following snippet throws an exception.
      {{CriteriaBuilder builder = entityManager.getCriteriaBuilder();
      CriteriaUpdate<Person> upd = builder.createCriteriaUpdate(Person.class);
      upd.from(Person.class);
      upd.set(Person_.subject, builder.nullLiteral(Subject.class));}}

      Stacktrace:
      {{java.lang.IllegalArgumentException: Could not convert java type [org.hibernate.bugs.entity.Subject] to Hibernate type
      at org.hibernate.query.criteria.internal.compile.CriteriaCompiler$1.getCastType(CriteriaCompiler.java:120)
      at org.hibernate.query.criteria.internal.expression.NullLiteralExpression.render(NullLiteralExpression.java:31)
      at org.hibernate.query.criteria.internal.CriteriaUpdateImpl.renderAssignments(CriteriaUpdateImpl.java:133)
      at org.hibernate.query.criteria.internal.CriteriaUpdateImpl.renderQuery(CriteriaUpdateImpl.java:118)
      at org.hibernate.query.criteria.internal.AbstractManipulationCriteriaQuery.interpret(AbstractManipulationCriteriaQuery.java:102)
      at org.hibernate.query.criteria.internal.compile.CriteriaCompiler.compile(CriteriaCompiler.java:127)
      at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3591)
      at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:203)
      at org.hibernate.bugs.JPAUnitTestCase.couldNotConvertJavaType(JPAUnitTestCase.java:40)}}

      Hibernate ORM versions 5.1.0 and 5.2.0 are OK.
      Test case included.
      !!! Fixed test case uploaded. See latest test case file. !!!

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: