Skip to content

Commit 62b6ed5

Browse files
jrenaatbeikov
authored andcommitted
HHH-18765 - Add test for issue
Signed-off-by: Jan Schatteman <[email protected]>
1 parent 96cba56 commit 62b6ed5

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* SPDX-License-Identifier: LGPL-2.1-or-later
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.type;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.Id;
9+
import org.hibernate.dialect.OracleDialect;
10+
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
11+
import org.hibernate.testing.orm.junit.DomainModel;
12+
import org.hibernate.testing.orm.junit.Jira;
13+
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
14+
import org.hibernate.testing.orm.junit.SessionFactory;
15+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
16+
import org.hibernate.testing.orm.junit.SkipForDialect;
17+
import org.junit.jupiter.api.Assertions;
18+
import org.junit.jupiter.api.Test;
19+
20+
/**
21+
* @author Jan Schatteman
22+
*/
23+
@DomainModel (
24+
annotatedClasses = {BooleanArrayToStringTest.TestEntity.class}
25+
)
26+
@SessionFactory
27+
public class BooleanArrayToStringTest {
28+
29+
@Test
30+
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTypedArrays.class)
31+
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsArrayToString.class)
32+
@SkipForDialect( dialectClass = OracleDialect.class, reason = "External driver fix required")
33+
@Jira( value = "https://hibernate.atlassian.net/browse/HHH-18765" )
34+
public void testBooleanArrayToStringFunction(SessionFactoryScope scope) {
35+
scope.inTransaction(
36+
session -> session.persist( new TestEntity(1L, new Boolean[]{Boolean.FALSE, Boolean.FALSE, null, Boolean.TRUE}) )
37+
);
38+
scope.inTransaction(
39+
session -> {
40+
String s = session.createQuery( "select array_to_string(t.theBoolean, ';', 'null') "
41+
+ "from TestEntity t", String.class ).getSingleResult();
42+
Assertions.assertEquals("false;false;null;true", s);
43+
}
44+
);
45+
scope.inTransaction(
46+
session -> session.createMutationQuery( "delete from TestEntity" ).executeUpdate()
47+
);
48+
}
49+
50+
@Entity(name = "TestEntity")
51+
public static class TestEntity {
52+
@Id
53+
private Long id;
54+
private Boolean[] theBoolean;
55+
56+
public TestEntity() {
57+
}
58+
59+
public TestEntity(Long id, Boolean[] theBoolean) {
60+
this.id = id;
61+
this.theBoolean = theBoolean;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)