diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java index 7b08a86767..eaf91defa8 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java @@ -924,7 +924,7 @@ public class OracleDialect extends Dialect { @Override public String getCurrentTimestampSelectString() { - return "select systimestamp from dual"; + return getVersion().isSameOrAfter( 23 ) ? "select systimestamp" : "select systimestamp from dual"; } @@ -971,7 +971,7 @@ public class OracleDialect extends Dialect { @Override public String getSelectGUIDString() { - return "select rawtohex(sys_guid()) from dual"; + return getVersion().isSameOrAfter( 23 ) ? "select rawtohex(sys_guid())" : "select rawtohex(sys_guid()) from dual"; } @Override @@ -1189,7 +1189,7 @@ public class OracleDialect extends Dialect { @Override public String getCurrentSchemaCommand() { - return "SELECT SYS_CONTEXT('USERENV','CURRENT_SCHEMA') FROM DUAL"; + return getVersion().isSameOrAfter( 23 ) ? "select sys_context('USERENV','CURRENT_SCHEMA')" : "SELECT SYS_CONTEXT('USERENV','CURRENT_SCHEMA') FROM DUAL"; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/OracleSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/OracleSqlAstTranslator.java index cf8d9e5ced..613d6af18b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/OracleSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/OracleSqlAstTranslator.java @@ -540,7 +540,7 @@ public class OracleSqlAstTranslator extends SqlAstTrans @Override protected String getFromDualForSelectOnly() { - return getFromDual(); + return getDialect().getVersion().isSameOrAfter( 23 ) ? super.getFromDualForSelectOnly() : getFromDual(); } private boolean supportsOffsetFetchClause() { @@ -609,7 +609,8 @@ public class OracleSqlAstTranslator extends SqlAstTrans appendSql( valueBinding.getColumnReference().getColumnExpression() ); } - appendSql( " from dual)" ); + appendSql( getFromDualForSelectOnly() ); + appendSql( ")" ); renderMergeSourceAlias(); }