HHH-13788 Fix default IdentifierHelper case strategy
This commit is contained in:
parent
b17e17cdb6
commit
f1a5b2cbca
|
@ -6,6 +6,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.AnsiSqlKeywords;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
|
@ -22,4 +30,15 @@ public class MariaDBDialect extends MySQL5Dialect {
|
||||||
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
||||||
return InnoDBStorageEngine.INSTANCE;
|
return InnoDBStorageEngine.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
// some MariaDB drivers does not return case strategy info
|
||||||
|
builder.setUnquotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
builder.setQuotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
|
||||||
|
return super.buildIdentifierHelper( builder, dbMetaData );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import java.sql.CallableStatement;
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
@ -27,6 +28,9 @@ import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitHelper;
|
import org.hibernate.dialect.pagination.LimitHelper;
|
||||||
import org.hibernate.dialect.unique.MySQLUniqueDelegate;
|
import org.hibernate.dialect.unique.MySQLUniqueDelegate;
|
||||||
import org.hibernate.dialect.unique.UniqueDelegate;
|
import org.hibernate.dialect.unique.UniqueDelegate;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
import org.hibernate.engine.spi.RowSelection;
|
import org.hibernate.engine.spi.RowSelection;
|
||||||
import org.hibernate.exception.LockAcquisitionException;
|
import org.hibernate.exception.LockAcquisitionException;
|
||||||
import org.hibernate.exception.LockTimeoutException;
|
import org.hibernate.exception.LockTimeoutException;
|
||||||
|
@ -562,6 +566,18 @@ public class MySQLDialect extends Dialect {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
if ( dbMetaData == null ) {
|
||||||
|
builder.setUnquotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
builder.setQuotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.buildIdentifierHelper( builder, dbMetaData );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNotExpression(String expression) {
|
public String getNotExpression(String expression) {
|
||||||
return "not (" + expression + ")";
|
return "not (" + expression + ")";
|
||||||
|
|
|
@ -29,6 +29,9 @@ import org.hibernate.dialect.identity.PostgreSQL81IdentityColumnSupport;
|
||||||
import org.hibernate.dialect.pagination.AbstractLimitHandler;
|
import org.hibernate.dialect.pagination.AbstractLimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitHelper;
|
import org.hibernate.dialect.pagination.LimitHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
import org.hibernate.engine.spi.RowSelection;
|
import org.hibernate.engine.spi.RowSelection;
|
||||||
import org.hibernate.exception.LockAcquisitionException;
|
import org.hibernate.exception.LockAcquisitionException;
|
||||||
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
||||||
|
@ -76,6 +79,18 @@ public class PostgreSQL81Dialect extends Dialect {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
if ( dbMetaData == null ) {
|
||||||
|
builder.setUnquotedCaseStrategy( IdentifierCaseStrategy.LOWER );
|
||||||
|
builder.setQuotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.buildIdentifierHelper( builder, dbMetaData );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a PostgreSQL81Dialect
|
* Constructs a PostgreSQL81Dialect
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -19,6 +21,9 @@ import org.hibernate.dialect.identity.SQLServerIdentityColumnSupport;
|
||||||
import org.hibernate.dialect.pagination.LegacyLimitHandler;
|
import org.hibernate.dialect.pagination.LegacyLimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.TopLimitHandler;
|
import org.hibernate.dialect.pagination.TopLimitHandler;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.StringType;
|
import org.hibernate.type.StringType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
@ -107,6 +112,18 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IdentifierHelper buildIdentifierHelper(
|
||||||
|
IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException {
|
||||||
|
|
||||||
|
if ( dbMetaData == null ) {
|
||||||
|
builder.setUnquotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
builder.setQuotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.buildIdentifierHelper( builder, dbMetaData );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsLimitOffset() {
|
public boolean supportsLimitOffset() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class IdentifierHelperBuilder {
|
||||||
private boolean globallyQuoteIdentifiers = false;
|
private boolean globallyQuoteIdentifiers = false;
|
||||||
private boolean skipGlobalQuotingForColumnDefinitions = false;
|
private boolean skipGlobalQuotingForColumnDefinitions = false;
|
||||||
private boolean autoQuoteKeywords = true;
|
private boolean autoQuoteKeywords = true;
|
||||||
private IdentifierCaseStrategy unquotedCaseStrategy = IdentifierCaseStrategy.MIXED;
|
private IdentifierCaseStrategy unquotedCaseStrategy = IdentifierCaseStrategy.UPPER;
|
||||||
private IdentifierCaseStrategy quotedCaseStrategy = IdentifierCaseStrategy.MIXED;
|
private IdentifierCaseStrategy quotedCaseStrategy = IdentifierCaseStrategy.MIXED;
|
||||||
|
|
||||||
public static IdentifierHelperBuilder from(JdbcEnvironment jdbcEnvironment) {
|
public static IdentifierHelperBuilder from(JdbcEnvironment jdbcEnvironment) {
|
||||||
|
|
Loading…
Reference in New Issue