From 53d38262ba3a9e45bd7f759ca6b2bca357a20208 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 8 Jan 2022 12:32:01 +0100 Subject: [PATCH] test showing selecting enum value causes NPE --- .../orm/test/query/hql/LiteralTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/LiteralTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/LiteralTests.java index 9175cb40f2..79139f3cfa 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/LiteralTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/LiteralTests.java @@ -34,7 +34,7 @@ import static org.hamcrest.Matchers.is; */ @SuppressWarnings({"deprecation","WeakerAccess"}) @ServiceRegistry -@DomainModel( standardModels = StandardDomainModel.GAMBIT ) +@DomainModel( standardModels = {StandardDomainModel.GAMBIT, StandardDomainModel.ANIMAL} ) @SessionFactory public class LiteralTests { @@ -265,4 +265,19 @@ public class LiteralTests { } ); } + + @Test + public void testEnums(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + session.createQuery( "from Zoo where classification=COOL" ).getResultList(); + session.createQuery( "from Zoo where classification=org.hibernate.testing.orm.domain.animal.Classification.COOL" ).getResultList(); + + assertThat( session.createQuery( "select org.hibernate.testing.orm.domain.animal.Classification.LAME" ) + .getSingleResult(), is( org.hibernate.testing.orm.domain.animal.Classification.LAME ) ); + assertThat( session.createQuery( "select org.hibernate.testing.orm.domain.gambit.EntityOfBasics$Gender.MALE" ) + .getSingleResult(), is( org.hibernate.testing.orm.domain.gambit.EntityOfBasics.Gender.MALE ) ); + } + ); + } }