Fix several tests failing on Oracle 11 and some others on older dbs
This commit is contained in:
parent
2c1ee27038
commit
4e9a643346
|
@ -433,12 +433,47 @@ public class OracleLegacySqlAstTranslator<T extends JdbcOperation> extends Abstr
|
|||
rhs.accept( this );
|
||||
appendSql( ')' );
|
||||
break;
|
||||
case SqlTypes.ARRAY:
|
||||
switch ( operator ) {
|
||||
case DISTINCT_FROM:
|
||||
appendSql( "decode(" );
|
||||
arrayToString( lhs );
|
||||
appendSql( ',' );
|
||||
arrayToString( rhs );
|
||||
appendSql( ",0,1)=1" );
|
||||
break;
|
||||
case NOT_DISTINCT_FROM:
|
||||
appendSql( "decode(" );
|
||||
arrayToString( lhs );
|
||||
appendSql( ',' );
|
||||
arrayToString( rhs );
|
||||
appendSql( ",0,1)=0" );
|
||||
break;
|
||||
default:
|
||||
arrayToString( lhs );
|
||||
appendSql( operator.sqlText() );
|
||||
arrayToString( rhs );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
renderComparisonEmulateDecode( lhs, operator, rhs );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void arrayToString(Expression expression) {
|
||||
appendSql("case when ");
|
||||
expression.accept( this );
|
||||
appendSql(" is not null then (select listagg(column_value||',')");
|
||||
if ( !getDialect().getVersion().isSameOrAfter( 18 ) ) {
|
||||
// The within group clause became optional in 18
|
||||
appendSql(" within group(order by rownum)");
|
||||
}
|
||||
appendSql("||';' from table(");
|
||||
expression.accept( this );
|
||||
appendSql(")) else null end");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSelectTupleComparison(
|
||||
List<SqlSelection> lhsExpressions,
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Locale;
|
|||
|
||||
import static java.sql.Types.ARRAY;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.hibernate.internal.util.StringHelper.truncate;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
|
||||
|
||||
/**
|
||||
|
@ -233,8 +234,10 @@ public class OracleNestedTableJdbcType implements JdbcType {
|
|||
final Dialect dialect = database.getDialect();
|
||||
final BasicPluralJavaType<?> pluralJavaType = (BasicPluralJavaType<?>) javaType;
|
||||
String elementTypeName = getTypeName( pluralJavaType.getElementJavaType(), dialect );
|
||||
return " nested table " + columnName
|
||||
+ " store as \"" + tableName + " " + columnName + " " + elementTypeName + "\"";
|
||||
return " nested table " + columnName + " store as \"" + truncate(
|
||||
tableName + " " + columnName + " " + elementTypeName,
|
||||
dialect.getMaxIdentifierLength()
|
||||
) + "\"";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -470,7 +470,12 @@ public class OracleSqlAstTranslator<T extends JdbcOperation> extends SqlAstTrans
|
|||
private void arrayToString(Expression expression) {
|
||||
appendSql("case when ");
|
||||
expression.accept( this );
|
||||
appendSql(" is not null then (select listagg(column_value||',')||';' from table(");
|
||||
appendSql(" is not null then (select listagg(column_value||',')");
|
||||
if ( !getDialect().getVersion().isSameOrAfter( 18 ) ) {
|
||||
// The within group clause became optional in 18
|
||||
appendSql(" within group(order by rownum)");
|
||||
}
|
||||
appendSql("||';' from table(");
|
||||
expression.accept( this );
|
||||
appendSql(")) else null end");
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -18,7 +17,6 @@ import jakarta.persistence.Entity;
|
|||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
|
@ -47,6 +45,7 @@ public class RefreshAndInheritanceTest {
|
|||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ManufacturerCompany manufacturerCompany = new ManufacturerCompany();
|
||||
manufacturerCompany.setId( 1L );
|
||||
manufacturerCompany.setComputerSystem( new ManufacturerComputerSystem() );
|
||||
|
||||
Person person = new Person();
|
||||
|
@ -85,7 +84,6 @@ public class RefreshAndInheritanceTest {
|
|||
@DiscriminatorColumn(name = "CompanyType", discriminatorType = DiscriminatorType.INTEGER)
|
||||
public static abstract class Company {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
protected long id;
|
||||
|
||||
@OneToMany(mappedBy = "company", orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
|
@ -99,6 +97,10 @@ public class RefreshAndInheritanceTest {
|
|||
people.add( person );
|
||||
person.setCompany( this );
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "ComputerSystem")
|
||||
|
@ -106,7 +108,7 @@ public class RefreshAndInheritanceTest {
|
|||
@DiscriminatorColumn(name = "CompanyType", discriminatorType = DiscriminatorType.INTEGER)
|
||||
public static abstract class ComputerSystem {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
|
@ -139,7 +141,7 @@ public class RefreshAndInheritanceTest {
|
|||
@Entity(name = "Person")
|
||||
public static class Person {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
private String firstName;
|
||||
|
|
|
@ -52,7 +52,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
|||
@Setting(name = AvailableSettings.FORMAT_SQL, value = "false")
|
||||
}
|
||||
)
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
@RequiresDialect(value = H2Dialect.class, majorVersion = 2, comment = "H2 didn't support SQL arrays before version 2")
|
||||
@JiraKey("HHH-16469")
|
||||
public class DepthOneBatchTest {
|
||||
|
||||
|
|
|
@ -1892,8 +1892,9 @@ public class FunctionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SkipForDialect(dialectClass = OracleDialect.class)
|
||||
@SkipForDialect(dialectClass = MariaDBDialect.class)
|
||||
@SkipForDialect(dialectClass = OracleDialect.class, reason = "HHH-16576")
|
||||
@SkipForDialect(dialectClass = MariaDBDialect.class, reason = "HHH-16576")
|
||||
@SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 5, reason = "HHH-16576")
|
||||
public void testMaxOverUnion(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
|
|
|
@ -148,6 +148,6 @@ public class EnumSet extends BaseEnversJPAFunctionalTestCase {
|
|||
}
|
||||
|
||||
private void verifyMapping(JdbcMapping jdbcMapping) {
|
||||
assertThat( jdbcMapping.getJdbcType().getJdbcTypeCode() ).isIn( Types.VARCHAR, SqlTypes.ENUM );
|
||||
assertThat( jdbcMapping.getJdbcType().getJdbcTypeCode() ).isIn( Types.VARCHAR, Types.NVARCHAR, SqlTypes.ENUM );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue