From a82c2169cf105870c1cae5da06b0b981c52151a7 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 15 Feb 2023 08:18:12 -0600 Subject: [PATCH] HHH-16182 - JPA derived query methods failing when boolean mapping using YesNoConverter --- .../mapping/basic/BooleanMappingTests.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BooleanMappingTests.java b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BooleanMappingTests.java index 620508fc50..eb817a76fa 100644 --- a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BooleanMappingTests.java +++ b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BooleanMappingTests.java @@ -7,11 +7,6 @@ package org.hibernate.userguide.mapping.basic; import java.sql.Types; -import jakarta.persistence.Basic; -import jakarta.persistence.Convert; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import jakarta.persistence.Table; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping; @@ -20,10 +15,17 @@ import org.hibernate.persister.entity.EntityPersister; import org.hibernate.type.internal.ConvertedBasicTypeImpl; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.Jira; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.Test; +import jakarta.persistence.Basic; +import jakarta.persistence.Convert; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; @@ -93,8 +95,24 @@ public class BooleanMappingTests { equalTo( Types.INTEGER ) ); } + } + @Test + @Jira( "https://hibernate.atlassian.net/browse/HHH-16182" ) + public void testQueryLiteralUsage(SessionFactoryScope scope) { + scope.inTransaction( (session) -> { + session.createSelectionQuery( "from EntityOfBooleans where convertedYesNo = true" ).list(); + session.createSelectionQuery( "from EntityOfBooleans where convertedTrueFalse = true" ).list(); + session.createSelectionQuery( "from EntityOfBooleans where convertedNumeric = true" ).list(); + session.createMutationQuery( "delete EntityOfBooleans where convertedYesNo = true" ).executeUpdate(); + session.createMutationQuery( "delete EntityOfBooleans where convertedTrueFalse = true" ).executeUpdate(); + session.createMutationQuery( "delete EntityOfBooleans where convertedNumeric = true" ).executeUpdate(); + + session.createMutationQuery( "update EntityOfBooleans set convertedYesNo = true" ).executeUpdate(); + session.createMutationQuery( "update EntityOfBooleans set convertedTrueFalse = true" ).executeUpdate(); + session.createMutationQuery( "update EntityOfBooleans set convertedNumeric = true" ).executeUpdate(); + } ); } @Entity(name = "EntityOfBooleans")