HHH-18765 - Add test for issue

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2024-10-25 22:13:47 +02:00 committed by Christian Beikov
parent 96cba56591
commit 62b6ed5cae
1 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.orm.test.type;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.SkipForDialect;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* @author Jan Schatteman
*/
@DomainModel (
annotatedClasses = {BooleanArrayToStringTest.TestEntity.class}
)
@SessionFactory
public class BooleanArrayToStringTest {
@Test
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTypedArrays.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsArrayToString.class)
@SkipForDialect( dialectClass = OracleDialect.class, reason = "External driver fix required")
@Jira( value = "https://hibernate.atlassian.net/browse/HHH-18765" )
public void testBooleanArrayToStringFunction(SessionFactoryScope scope) {
scope.inTransaction(
session -> session.persist( new TestEntity(1L, new Boolean[]{Boolean.FALSE, Boolean.FALSE, null, Boolean.TRUE}) )
);
scope.inTransaction(
session -> {
String s = session.createQuery( "select array_to_string(t.theBoolean, ';', 'null') "
+ "from TestEntity t", String.class ).getSingleResult();
Assertions.assertEquals("false;false;null;true", s);
}
);
scope.inTransaction(
session -> session.createMutationQuery( "delete from TestEntity" ).executeUpdate()
);
}
@Entity(name = "TestEntity")
public static class TestEntity {
@Id
private Long id;
private Boolean[] theBoolean;
public TestEntity() {
}
public TestEntity(Long id, Boolean[] theBoolean) {
this.id = id;
this.theBoolean = theBoolean;
}
}
}