cleanup IntelliJ warnings in dialect package

This commit is contained in:
Gavin King 2024-02-08 14:27:56 +01:00
parent b571b22777
commit 69776bc305
30 changed files with 28 additions and 153 deletions

View File

@ -61,7 +61,6 @@ import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.spi.ColumnTypeInformation;
import org.hibernate.type.JavaObjectType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeConstructor;
import org.hibernate.type.descriptor.jdbc.ObjectNullAsBinaryTypeJdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
import org.hibernate.type.descriptor.jdbc.VarbinaryJdbcType;

View File

@ -84,7 +84,7 @@ class CockroachDialectQueryHints {
StringBuilder buffer = new StringBuilder();
int start = 0;
while ( m.find() ) {
buffer.append( query.substring( start, m.start() ) );
buffer.append(query, start, m.start());
if ( m.group( 1 ) == null ) {
buffer.append( " inner" );

View File

@ -28,7 +28,6 @@ import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.expression.Summarization;
import org.hibernate.sql.ast.tree.from.NamedTableReference;
import org.hibernate.sql.ast.tree.from.QueryPartTableReference;
import org.hibernate.sql.ast.tree.from.TableGroup;
@ -558,23 +557,6 @@ public class DB2SqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAst
emulateSelectTupleComparison( lhsExpressions, tuple.getExpressions(), operator, true );
}
@Override
protected void renderPartitionItem(Expression expression) {
if ( expression instanceof Literal ) {
appendSql( "()" );
}
else if ( expression instanceof Summarization ) {
Summarization summarization = (Summarization) expression;
appendSql( summarization.getKind().sqlText() );
appendSql( OPEN_PARENTHESIS );
renderCommaSeparated( summarization.getGroupings() );
appendSql( CLOSE_PARENTHESIS );
}
else {
expression.accept( this );
}
}
@Override
protected boolean supportsRowValueConstructorSyntax() {
return false;

View File

@ -31,7 +31,7 @@ import org.hibernate.type.spi.TypeConfiguration;
* To support UDTs, we require that a transform exists for the UDT that serializes from SQL to XML
* and deserializes to SQL from UDT. This means that from the JDBC perspective, this is an XML type,
* but the database models it internally as UDT.
*
* <p>
* The {@link org.hibernate.dialect.aggregate.DB2AggregateSupport} generates the functions and transforms for this
* process automatically, but note that all of this is only used for functions and native queries.
* By default, we select individual struct parts to avoid the encoding/decoding.

View File

@ -131,16 +131,6 @@ public class DB2iDialect extends DB2Dialect {
return true;
}
@Override
public boolean supportsLateral() {
return true;
}
@Override
public boolean supportsRecursiveCTE() {
return true;
}
@Override
public SqlAstTranslatorFactory getSqlAstTranslatorFactory() {
return new StandardSqlAstTranslatorFactory() {

View File

@ -143,16 +143,6 @@ public class DB2zDialect extends DB2Dialect {
return true;
}
@Override
public boolean supportsLateral() {
return true;
}
@Override
public boolean supportsRecursiveCTE() {
return true;
}
@Override
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
final StringBuilder pattern = new StringBuilder();

View File

@ -407,7 +407,7 @@ public class DerbyDialect extends Dialect {
* no functions at all for calendaring, but we can
* emulate the most basic functionality of extract()
* using the functions it does have.
*
* <p>
* The only supported {@link TemporalUnit}s are:
* {@link TemporalUnit#YEAR},
* {@link TemporalUnit#MONTH}
@ -559,11 +559,6 @@ public class DerbyDialect extends Dialect {
return false;
}
@Override
public RowLockStrategy getWriteRowLockStrategy() {
return RowLockStrategy.NONE;
}
@Override
public RowLockStrategy getReadRowLockStrategy() {
return RowLockStrategy.NONE;

View File

@ -183,11 +183,6 @@ public class DerbySqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
}
}
@Override
protected String getForUpdate() {
return " for update";
}
@Override
protected String getForShare(int timeoutMillis) {
return " for read only";

View File

@ -179,7 +179,6 @@ import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeConstructor;
import org.hibernate.type.descriptor.jdbc.LongNVarcharJdbcType;
import org.hibernate.type.descriptor.jdbc.NCharJdbcType;
import org.hibernate.type.descriptor.jdbc.NClobJdbcType;
@ -1588,8 +1587,8 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
* <p>
* An implementation may set configuration properties from
* {@link #initDefaultProperties()}, though it is discouraged.
*
* @return a set of Hibernate configuration properties
the
* @return the Hibernate configuration properties
*
* @see #initDefaultProperties()
*/
@ -1778,9 +1777,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
}
final JdbcServices jdbcServices = session.getFactory().getFastSessionServices().jdbcServices;
try {
final LobCreator lobCreator = jdbcServices.getLobCreator(
session
);
final LobCreator lobCreator = jdbcServices.getLobCreator( session );
return original == null
? lobCreator.createBlob( ArrayHelper.EMPTY_BYTE_ARRAY )
: lobCreator.createBlob( original.getBinaryStream(), original.length() );
@ -4575,7 +4572,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
// Keep this here, rather than moving to Select.
// Some Dialects may need the hint to be appended to the very end or beginning
// of the finalized SQL statement, so wait until everything is processed.
if ( queryOptions.getDatabaseHints() != null && queryOptions.getDatabaseHints().size() > 0 ) {
if ( queryOptions.getDatabaseHints() != null && !queryOptions.getDatabaseHints().isEmpty() ) {
sql = getQueryHintString( sql, queryOptions.getDatabaseHints() );
}
if ( commentsEnabled && queryOptions.getComment() != null ) {

View File

@ -63,7 +63,6 @@ import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.internal.OptionalTableUpdate;
import org.hibernate.sql.model.jdbc.OptionalTableUpdateOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.descriptor.jdbc.H2FormatJsonJdbcType;
@ -335,11 +334,11 @@ public class H2Dialect extends Dialect {
}
/**
* H2 requires a very special emulation, because {@code unnest} is pretty much useless,
* due to https://github.com/h2database/h2database/issues/1815.
* This emulation uses {@code array_get}, {@code array_length} and {@code system_range} functions to roughly achieve the same,
* but requires that {@code system_range} is fed with a "maximum array size".
*/
* H2 requires a very special emulation, because {@code unnest} is pretty much useless,
* due to <a href="https://github.com/h2database/h2database/issues/1815">issue 1815</a>.
* This emulation uses {@code array_get}, {@code array_length} and {@code system_range} functions to roughly achieve the same,
* but requires that {@code system_range} is fed with a "maximum array size".
*/
protected int getMaximumArraySize() {
return 1000;
}
@ -954,12 +953,12 @@ public class H2Dialect extends Dialect {
return translator.createMergeOperation( optionalTableUpdate );
}
private static MutationOperation withoutMerge(
EntityMutationTarget mutationTarget,
OptionalTableUpdate optionalTableUpdate,
SessionFactoryImplementor factory) {
return new OptionalTableUpdateOperation( mutationTarget, optionalTableUpdate, factory );
}
// private static MutationOperation withoutMerge(
// EntityMutationTarget mutationTarget,
// OptionalTableUpdate optionalTableUpdate,
// SessionFactoryImplementor factory) {
// return new OptionalTableUpdateOperation( mutationTarget, optionalTableUpdate, factory );
// }
@Override
public ParameterMarkerStrategy getNativeParameterMarkerStrategy() {

View File

@ -17,7 +17,6 @@ import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.MutationStatement;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.cte.CteContainer;
import org.hibernate.sql.ast.tree.cte.CteTableGroup;

View File

@ -8,20 +8,16 @@ package org.hibernate.dialect;
import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.Stack;
import org.hibernate.query.IllegalQueryOperationException;
import org.hibernate.query.sqm.BinaryArithmeticOperator;
import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.cte.CteStatement;
import org.hibernate.sql.ast.tree.delete.DeleteStatement;
import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.Summarization;

View File

@ -369,11 +369,6 @@ public class HSQLDialect extends Dialect {
return false;
}
@Override
public String getForUpdateString() {
return " for update";
}
@Override
public LimitHandler getLimitHandler() {
return OffsetFetchLimitHandler.INSTANCE;

View File

@ -18,12 +18,10 @@ import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.MutationStatement;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression;
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
import org.hibernate.sql.ast.tree.expression.CaseSimpleExpression;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.SqlTuple;

View File

@ -185,11 +185,6 @@ public class MariaDBDialect extends MySQLDialect {
return false;
}
@Override
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
return InnoDBStorageEngine.INSTANCE;
}
@Override
public boolean supportsIfExistsBeforeConstraintName() {
return true;

View File

@ -228,11 +228,6 @@ public class MariaDBSqlAstTranslator<T extends JdbcOperation> extends AbstractSq
return useOffsetFetchClause( queryPart ) && getQueryPartForRowNumbering() != queryPart && supportsWindowFunctions() && !isRowsOnlyFetchClauseType( queryPart );
}
@Override
protected boolean supportsSimpleQueryGrouping() {
return true;
}
@Override
protected boolean shouldEmulateLateralWithIntersect(QueryPart queryPart) {
// Intersect emulation requires nested correlation when no simple query grouping is possible

View File

@ -35,7 +35,6 @@ import oracle.jdbc.OracleConnection;
import static java.sql.Types.ARRAY;
import static java.util.Collections.emptySet;
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
/**
* Descriptor for {@link Types#ARRAY ARRAY} handling.

View File

@ -84,7 +84,6 @@ import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
import org.hibernate.type.descriptor.jdbc.AggregateJdbcType;
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeConstructor;
import org.hibernate.type.descriptor.jdbc.NullJdbcType;
import org.hibernate.type.descriptor.jdbc.ObjectNullAsNullTypeJdbcType;
import org.hibernate.type.descriptor.jdbc.OracleJsonBlobJdbcType;

View File

@ -35,7 +35,6 @@ 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;
/**
* Descriptor for {@link Types#ARRAY ARRAY} handling.
@ -113,13 +112,13 @@ public class OracleNestedTableJdbcType implements JdbcType {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
st.setArray( index, getArray( value, containerJavaType, options ) );
st.setArray( index, getArray( value, options ) );
}
@Override
protected void doBind(CallableStatement st, X value, String name, WrapperOptions options)
throws SQLException {
final java.sql.Array arr = getArray( value, containerJavaType, options );
final java.sql.Array arr = getArray( value, options );
try {
st.setObject( name, arr, ARRAY );
}
@ -128,7 +127,7 @@ public class OracleNestedTableJdbcType implements JdbcType {
}
}
private java.sql.Array getArray(X value, BasicPluralJavaType<X> containerJavaType, WrapperOptions options)
private java.sql.Array getArray(X value, WrapperOptions options)
throws SQLException {
//noinspection unchecked
final Class<Object[]> arrayClass = (Class<Object[]>) Array.newInstance(

View File

@ -12,7 +12,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.sql.ast.SqlAstTranslator;
@ -40,25 +39,17 @@ public class PostgreSQLCastingIntervalSecondJdbcType implements AdjustableJdbcTy
@Override
public JdbcType resolveIndicatedType(JdbcTypeIndicators indicators, JavaType<?> domainJtd) {
final int scale;
if ( indicators.getColumnScale() == JdbcTypeIndicators.NO_COLUMN_SCALE ) {
scale = domainJtd.getDefaultSqlScale(
indicators.getTypeConfiguration()
.getServiceRegistry()
.getService( JdbcServices.class )
.getDialect(),
this
);
}
else {
scale = indicators.getColumnScale();
}
final int scale = indicators.getColumnScale() == JdbcTypeIndicators.NO_COLUMN_SCALE
? domainJtd.getDefaultSqlScale( indicators.getDialect(), this )
: indicators.getColumnScale();
if ( scale > 6 ) {
// Since the maximum allowed scale on PostgreSQL is 6 (microsecond precision),
// we have to switch to the numeric type if the value is greater
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.NUMERIC );
}
return this;
else {
return this;
}
}
@Override

View File

@ -82,7 +82,6 @@ import org.hibernate.type.descriptor.jdbc.AggregateJdbcType;
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeConstructor;
import org.hibernate.type.descriptor.jdbc.ObjectNullAsBinaryTypeJdbcType;
import org.hibernate.type.descriptor.jdbc.XmlJdbcType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;

View File

@ -9,7 +9,6 @@ package org.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.UUID;
import org.hibernate.type.descriptor.ValueBinder;

View File

@ -7,7 +7,6 @@
package org.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@ -101,12 +100,6 @@ public class PostgresPlusDialect extends PostgreSQLDialect {
return col;
}
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
ps.execute();
return (ResultSet) ps.getObject( 1 );
}
@Override
public String getSelectGUIDString() {
return "select uuid_generate_v1";

View File

@ -32,9 +32,7 @@ import org.hibernate.dialect.function.SqlServerConvertTruncFunction;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.SQLServerIdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.SQLServer2005LimitHandler;
import org.hibernate.dialect.pagination.SQLServer2012LimitHandler;
import org.hibernate.dialect.sequence.NoSequenceSupport;
import org.hibernate.dialect.sequence.SQLServer16SequenceSupport;
import org.hibernate.dialect.sequence.SQLServerSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;

View File

@ -16,16 +16,12 @@ import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.IllegalQueryOperationException;
import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
import org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.MutationStatement;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.delete.DeleteStatement;
import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.SqlTuple;
@ -281,7 +277,6 @@ public class SQLServerSqlAstTranslator<T extends JdbcOperation> extends SqlAstTr
}
protected OffsetFetchClauseMode getOffsetFetchClauseMode(QueryPart queryPart) {
final DatabaseVersion version = getDialect().getVersion();
final boolean hasLimit;
final boolean hasOffset;
if ( queryPart.isRoot() && hasLimit() ) {
@ -369,11 +364,6 @@ public class SQLServerSqlAstTranslator<T extends JdbcOperation> extends SqlAstTr
super.visitSelectClause( selectClause );
}
@Override
protected boolean needsRowsToSkip() {
return false;
}
@Override
protected void visitSqlSelections(SelectClause selectClause) {
final QuerySpec querySpec = (QuerySpec) getQueryPartStack().getCurrent();

View File

@ -55,7 +55,7 @@ class SpannerDialectTableExporter implements Exporter<Table> {
// a typical table that corresponds to an entity type
keyColumns = table.getPrimaryKey().getColumns();
}
else if ( table.getForeignKeys().size() > 0 ) {
else if ( !table.getForeignKeys().isEmpty() ) {
// a table with no PK's but has FK's; often corresponds to element collection properties
keyColumns = table.getColumns();
}

View File

@ -15,7 +15,6 @@ import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.cte.CteStatement;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.SqlTuple;

View File

@ -14,7 +14,6 @@ import java.sql.Types;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.cfg.DialectSpecificSettings;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.TopLimitHandler;
import org.hibernate.engine.jdbc.Size;

View File

@ -27,7 +27,6 @@ import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression;
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
import org.hibernate.sql.ast.tree.expression.CaseSimpleExpression;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.AggregateColumnWriteExpression;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
@ -95,19 +94,6 @@ public class SybaseASESqlAstTranslator<T extends JdbcOperation> extends Abstract
}
}
@Override
protected void renderUpdateClause(UpdateStatement updateStatement) {
appendSql( "update " );
final Stack<Clause> clauseStack = getClauseStack();
try {
clauseStack.push( Clause.UPDATE );
renderDmlTargetTableExpression( updateStatement.getTargetTable() );
}
finally {
clauseStack.pop();
}
}
@Override
protected boolean supportsJoinsInDelete() {
return true;

View File

@ -40,7 +40,6 @@ import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.query.sqm.CastType;
import org.hibernate.query.sqm.IntervalType;
import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.TrimSpec;
import org.hibernate.query.sqm.internal.DomainParameterXref;
import org.hibernate.query.sqm.sql.SqmTranslator;
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;