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

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. !!!

Environment

Java 1.8.0_92

Status

Assignee

Andrea Boriero

Reporter

Tony Cramer

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Critical
Configure