Skip to content

Commit 351e3b4

Browse files
committed
HHH-18765 - fix error in the booleanarray_to_string auxiliary function for Oracle
Signed-off-by: Jan Schatteman <[email protected]>
1 parent 7bf6004 commit 351e3b4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/OracleUserDefinedTypeExporter.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,18 @@ public String[] getSqlCreateStrings(
6565
dialect
6666
);
6767
final String valueExpression = determineValueExpression( "t.value", elementSqlTypeCode, elementType );
68+
boolean isBooleanType = elementType.equalsIgnoreCase( "boolean" );
6869
return new String[] {
6970
"create or replace type " + arrayTypeName + " as varying array(" + arrayLength + ") of " + elementType,
71+
!isBooleanType ? "" :
72+
"create or replace function boolean_to_char(bool in boolean) return varchar2 is begin " +
73+
"return " +
74+
"case bool " +
75+
"when true then 'true' " +
76+
"when false then 'false' " +
77+
"else 'null' " +
78+
"end; " +
79+
"end;",
7080
"create or replace function " + arrayTypeName + "_cmp(a in " + arrayTypeName +
7181
", b in " + arrayTypeName + ") return number deterministic is begin " +
7282
"if a is null or b is null then return null; end if; " +
@@ -252,7 +262,7 @@ public String[] getSqlCreateStrings(
252262
"for i in 1 .. arr.count loop " +
253263
"if arr(i) is not null then " +
254264
"if length(res)<>0 then res:=res||sep; end if; " +
255-
"res:=res||arr(i); " +
265+
(!isBooleanType ? "res:=res||arr(i); " : "res:=res||boolean_to_char(arr(i)); ") +
256266
"elsif nullVal is not null then " +
257267
"if length(res)<>0 then res:=res||sep; end if; " +
258268
"res:=res||nullVal; " +

0 commit comments

Comments
 (0)