diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java b/hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java index c556e2086e..b7f514229b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java @@ -54,7 +54,7 @@ public class DurationIntervalSecondJdbcType implements JdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -71,7 +71,7 @@ public class DurationIntervalSecondJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getObject( paramIndex, Duration.class ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLIntervalSecondJdbcType.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLIntervalSecondJdbcType.java index 1bee1e9581..91987453ac 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLIntervalSecondJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLIntervalSecondJdbcType.java @@ -91,7 +91,7 @@ public class PostgreSQLIntervalSecondJdbcType implements AdjustableJdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -136,7 +136,7 @@ public class PostgreSQLIntervalSecondJdbcType implements AdjustableJdbcType { @Override public ValueExtractor getExtractor(JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return getJavaType().wrap( rs.getString( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLPGObjectJdbcType.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLPGObjectJdbcType.java index bd5e2ede34..08e1c12bec 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLPGObjectJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLPGObjectJdbcType.java @@ -83,7 +83,7 @@ public abstract class PostgreSQLPGObjectJdbcType implements JdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -126,7 +126,7 @@ public abstract class PostgreSQLPGObjectJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return ( (PostgreSQLPGObjectJdbcType) getJdbcType() ).fromString( diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAppender.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAppender.java index cbf314fef4..29d2fa46fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAppender.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAppender.java @@ -6,8 +6,6 @@ */ package org.hibernate.sql.ast.spi; -import java.io.IOException; - /** * Access to appending SQL fragments to an in-flight buffer * diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcType.java index 2e5f4661e3..1364e0b58f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcType.java @@ -46,13 +46,12 @@ public class BigIntJdbcType implements JdbcType { @Override public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - //noinspection unchecked - return new JdbcLiteralFormatterNumericData( javaType, Long.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, Long.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setLong( index, javaType.unwrap( value, Long.class, options ) ); @@ -69,7 +68,7 @@ public class BigIntJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getLong( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcType.java index 3943c0267c..407baf110d 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcType.java @@ -57,7 +57,7 @@ public abstract class BlobJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getBlob( paramIndex ), options ); @@ -91,7 +91,7 @@ public abstract class BlobJdbcType implements JdbcType { @Override public BasicBinder getBlobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -131,7 +131,7 @@ public abstract class BlobJdbcType implements JdbcType { @Override public BasicBinder getBlobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override public void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -155,7 +155,7 @@ public abstract class BlobJdbcType implements JdbcType { @Override public BasicBinder getBlobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -179,7 +179,7 @@ public abstract class BlobJdbcType implements JdbcType { @Override public BasicBinder getBlobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcType.java index 51512a1f3a..6c7af0b74a 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcType.java @@ -55,8 +55,7 @@ public class BooleanJdbcType implements AdjustableJdbcType { @Override public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - //noinspection unchecked - return new JdbcLiteralFormatterBoolean( javaType ); + return new JdbcLiteralFormatterBoolean<>( javaType ); } @Override @@ -72,7 +71,7 @@ public class BooleanJdbcType implements AdjustableJdbcType { } public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBindNull(PreparedStatement st, int index, WrapperOptions options) throws SQLException { st.setNull( index, options.getPreferredSqlTypeCodeForBoolean() ); @@ -80,7 +79,7 @@ public class BooleanJdbcType implements AdjustableJdbcType { @Override protected void doBindNull(CallableStatement st, String name, WrapperOptions options) throws SQLException { - st.setNull( name, options.getPreferredSqlTypeCodeForBoolean() );; + st.setNull( name, options.getPreferredSqlTypeCodeForBoolean() ); } @Override @@ -97,7 +96,7 @@ public class BooleanJdbcType implements AdjustableJdbcType { } public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getBoolean( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcType.java index 60fc6c0dfe..86ac86f7fb 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcType.java @@ -56,7 +56,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getClob( paramIndex ), options ); @@ -92,7 +92,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public BasicBinder getClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -126,7 +126,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public BasicBinder getClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -143,7 +143,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getString( paramIndex ), options ); @@ -172,7 +172,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public BasicBinder getClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -196,7 +196,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public BasicBinder getClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -230,7 +230,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public BasicBinder getClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -257,7 +257,7 @@ public abstract class ClobJdbcType implements AdjustableJdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getCharacterStream( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcType.java index 51980f9f42..5a85880e6b 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcType.java @@ -59,14 +59,13 @@ public class DateJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterTemporal( javaType, TemporalType.DATE ); + return new JdbcLiteralFormatterTemporal<>( javaType, TemporalType.DATE ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { final Date date = javaType.unwrap( value, Date.class, options ); @@ -94,7 +93,7 @@ public class DateJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getDate( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcType.java index fab83a8375..67041a0cce 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcType.java @@ -57,13 +57,12 @@ public class DecimalJdbcType implements JdbcType { @Override public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - //noinspection unchecked - return new JdbcLiteralFormatterNumericData( javaType, BigDecimal.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, BigDecimal.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setBigDecimal( index, javaType.unwrap( value, BigDecimal.class, options ) ); @@ -79,7 +78,7 @@ public class DecimalJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getBigDecimal( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcType.java index 3782745123..5f3d3eadf2 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcType.java @@ -67,13 +67,12 @@ public class DoubleJdbcType implements JdbcType { @Override public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - //noinspection unchecked - return new JdbcLiteralFormatterNumericData( javaType, Double.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, Double.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setDouble( index, javaType.unwrap( value, Double.class, options ) ); @@ -89,7 +88,7 @@ public class DoubleJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getDouble( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcType.java index e467e09201..edb9cdec09 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcType.java @@ -59,14 +59,13 @@ public class FloatJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterNumericData( javaType, Float.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, Float.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setFloat( index, javaType.unwrap( value, Float.class, options ) ); @@ -82,7 +81,7 @@ public class FloatJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getFloat( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcType.java index 3f1565fad7..db76e85122 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcType.java @@ -55,14 +55,13 @@ public class IntegerJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterNumericData( javaType, Integer.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, Integer.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setInt( index, javaType.unwrap( value, Integer.class, options ) ); @@ -78,7 +77,7 @@ public class IntegerJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getInt( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcLiteralFormatter.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcLiteralFormatter.java index a82679a370..132c776e26 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcLiteralFormatter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcLiteralFormatter.java @@ -9,27 +9,39 @@ package org.hibernate.type.descriptor.jdbc; import org.hibernate.dialect.Dialect; import org.hibernate.sql.ast.spi.SqlAppender; import org.hibernate.type.descriptor.WrapperOptions; +import org.hibernate.type.descriptor.java.JavaType; /** - * A formatter object for creating JDBC literals of a given type. - *

- * Generally this is obtained from the {@link JdbcType#getJdbcLiteralFormatter} method - * and would be specific to that Java and SQL type. - *

- * Performs a similar function as the legacy LiteralType, except continuing the paradigm - * shift from inheritance to composition/delegation. + * A formatter object for rendering values of a given {@linkplain JavaType Java type} + * as SQL literals of a certain {@linkplain JdbcType JDBC/SQL type}. Usually, an + * instance is obtained by calling {@link JdbcType#getJdbcLiteralFormatter(JavaType)}. + * + * @param the Java type that this instance formats as a SQL literal * * @author Steve Ebersole */ @FunctionalInterface public interface JdbcLiteralFormatter { - String NULL = "null"; - + /** + * Produces a string containing a SQL literal value representing the given Java value. + * + * @param value a Java object whose value can be represented as a SQL literal + * @param dialect the SQL dialect + * @return the SQL literal as a string + */ default String toJdbcLiteral(T value, Dialect dialect, WrapperOptions wrapperOptions) { final StringBuilder sb = new StringBuilder(); appendJdbcLiteral( sb::append, value, dialect, wrapperOptions ); return sb.toString(); } + /** + * Append a SQL literal representing the given Java value to a fragment of SQL which + * is being built. + * + * @param appender an operation that appends to the SQL fragment + * @param value a Java object whose value can be represented as a SQL literal + * @param dialect the SQL dialect + */ void appendJdbcLiteral(SqlAppender appender, T value, Dialect dialect, WrapperOptions wrapperOptions); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JsonJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JsonJdbcType.java index e9ba3824ee..5be75efcb0 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JsonJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JsonJdbcType.java @@ -45,7 +45,7 @@ public class JsonJdbcType implements JdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -72,7 +72,7 @@ public class JsonJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return options.getSessionFactory().getFastSessionServices().getJsonFormatMapper().fromString( diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcType.java index 34a5080501..c3e82c0951 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcType.java @@ -43,7 +43,7 @@ public abstract class NClobJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getNClob( paramIndex ), options ); @@ -79,7 +79,7 @@ public abstract class NClobJdbcType implements JdbcType { @Override public BasicBinder getNClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -113,7 +113,7 @@ public abstract class NClobJdbcType implements JdbcType { @Override public BasicBinder getNClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -137,7 +137,7 @@ public abstract class NClobJdbcType implements JdbcType { @Override public BasicBinder getNClobBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcType.java index 1000f38e96..c1c6293026 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcType.java @@ -86,7 +86,7 @@ public class NVarcharJdbcType implements AdjustableJdbcType { @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setNString( index, javaType.unwrap( value, String.class, options ) ); @@ -102,7 +102,7 @@ public class NVarcharJdbcType implements AdjustableJdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getNString( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcType.java index 04b95a9362..855243dcb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcType.java @@ -39,7 +39,7 @@ public class NullJdbcType implements JdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBindNull(PreparedStatement st, int index, WrapperOptions options) throws SQLException { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcType.java index bc14131744..2894ece371 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcType.java @@ -51,7 +51,7 @@ public class ObjectJdbcType implements JdbcType { return VarbinaryJdbcType.INSTANCE.getBinder( javaType ); } - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -73,7 +73,7 @@ public class ObjectJdbcType implements JdbcType { return VarbinaryJdbcType.INSTANCE.getExtractor( javaType ); } - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return (X) rs.getObject( paramIndex ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsBinaryTypeJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsBinaryTypeJdbcType.java index e0a75e860a..a96406ecbf 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsBinaryTypeJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsBinaryTypeJdbcType.java @@ -37,7 +37,7 @@ public class ObjectNullAsBinaryTypeJdbcType extends ObjectJdbcType { return VarbinaryJdbcType.INSTANCE.getBinder( javaType ); } - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBindNull(PreparedStatement st, int index, WrapperOptions options) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsNullTypeJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsNullTypeJdbcType.java index 0293256c1c..d76ff044e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsNullTypeJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullAsNullTypeJdbcType.java @@ -37,7 +37,7 @@ public class ObjectNullAsNullTypeJdbcType extends ObjectJdbcType { return VarbinaryJdbcType.INSTANCE.getBinder( javaType ); } - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBindNull(PreparedStatement st, int index, WrapperOptions options) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullResolvingJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullResolvingJdbcType.java index 03888c7372..00e6a3f14d 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullResolvingJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectNullResolvingJdbcType.java @@ -37,7 +37,7 @@ public class ObjectNullResolvingJdbcType extends ObjectJdbcType { return VarbinaryJdbcType.INSTANCE.getBinder( javaType ); } - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBindNull(PreparedStatement st, int index, WrapperOptions options) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcType.java index ebd56e31a5..a9994d0e2d 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcType.java @@ -55,14 +55,13 @@ public class SmallIntJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterNumericData( javaType, Short.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, Short.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setShort( index, javaType.unwrap( value, Short.class, options ) ); @@ -78,7 +77,7 @@ public class SmallIntJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getShort( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcType.java index d094a58a84..f8efeeece3 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcType.java @@ -59,14 +59,13 @@ public class TimeJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterTemporal( javaType, TemporalType.TIME ); + return new JdbcLiteralFormatterTemporal<>( javaType, TemporalType.TIME ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { final Time time = javaType.unwrap( value, Time.class, options ); @@ -100,7 +99,7 @@ public class TimeJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return options.getJdbcTimeZone() != null ? diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcType.java index 7af21ca1bc..f20b213df0 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcType.java @@ -59,14 +59,13 @@ public class TimestampJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterTemporal( javaType, TemporalType.TIMESTAMP ); + return new JdbcLiteralFormatterTemporal<>( javaType, TemporalType.TIMESTAMP ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { final Timestamp timestamp = javaType.unwrap( value, Timestamp.class, options ); @@ -100,7 +99,7 @@ public class TimestampJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return options.getJdbcTimeZone() != null ? diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcType.java index 21fad6bde2..643250398f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcType.java @@ -58,14 +58,13 @@ public class TimestampWithTimeZoneJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterTemporal( javaType, TemporalType.TIMESTAMP ); + return new JdbcLiteralFormatterTemporal<>( javaType, TemporalType.TIMESTAMP ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind( PreparedStatement st, @@ -107,7 +106,7 @@ public class TimestampWithTimeZoneJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int position, WrapperOptions wrapperOptions) throws SQLException { try { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcType.java index efb8fbaffd..78e3a383c2 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcType.java @@ -58,14 +58,13 @@ public class TinyIntJdbcType implements JdbcType { } @Override - @SuppressWarnings("unchecked") public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - return new JdbcLiteralFormatterNumericData( javaType, Byte.class ); + return new JdbcLiteralFormatterNumericData<>( javaType, Byte.class ); } @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setByte( index, javaType.unwrap( value, Byte.class, options ) ); @@ -81,7 +80,7 @@ public class TinyIntJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getByte( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/UUIDJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/UUIDJdbcType.java index 8549c63c9f..0ffa146f5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/UUIDJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/UUIDJdbcType.java @@ -47,7 +47,7 @@ public class UUIDJdbcType implements JdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -64,7 +64,7 @@ public class UUIDJdbcType implements JdbcType { @Override public ValueExtractor getExtractor(JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return getJavaType().wrap( rs.getObject( paramIndex, UUID.class ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcType.java index b47f4d0c2d..db80cde5be 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcType.java @@ -64,8 +64,7 @@ public class VarbinaryJdbcType implements AdjustableJdbcType { @Override public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaType) { - //noinspection unchecked - return supportsLiterals ? new JdbcLiteralFormatterBinary( javaType ) : null; + return supportsLiterals ? new JdbcLiteralFormatterBinary<>( javaType ) : null; } @Override @@ -77,7 +76,7 @@ public class VarbinaryJdbcType implements AdjustableJdbcType { } public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { @@ -93,7 +92,7 @@ public class VarbinaryJdbcType implements AdjustableJdbcType { } public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getBytes( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcType.java index 54904c01f8..43748789c5 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcType.java @@ -86,7 +86,7 @@ public class VarcharJdbcType implements AdjustableJdbcType { @Override public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setString( index, javaType.unwrap( value, String.class, options ) ); @@ -102,7 +102,7 @@ public class VarcharJdbcType implements AdjustableJdbcType { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getString( paramIndex ), options ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBinary.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBinary.java index 5ba2c7263c..8b6d93adbd 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBinary.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBinary.java @@ -13,12 +13,13 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.spi.BasicJdbcLiteralFormatter; /** - * JdbcLiteralFormatter implementation for handling binary literals + * {@link org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter} + * implementation for handling binary literals * * @author Gavin King */ -public class JdbcLiteralFormatterBinary extends BasicJdbcLiteralFormatter { - public JdbcLiteralFormatterBinary(JavaType javaType) { +public class JdbcLiteralFormatterBinary extends BasicJdbcLiteralFormatter { + public JdbcLiteralFormatterBinary(JavaType javaType) { super( javaType ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBoolean.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBoolean.java index 28e9e26d93..7edc47fbb9 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBoolean.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterBoolean.java @@ -13,12 +13,13 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.spi.BasicJdbcLiteralFormatter; /** - * JdbcLiteralFormatter implementation for handling boolean literals + * {@link org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter} + * implementation for handling boolean literals * * @author Steve Ebersole */ -public class JdbcLiteralFormatterBoolean extends BasicJdbcLiteralFormatter { - public JdbcLiteralFormatterBoolean(JavaType javaType) { +public class JdbcLiteralFormatterBoolean extends BasicJdbcLiteralFormatter { + public JdbcLiteralFormatterBoolean(JavaType javaType) { super( javaType ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterCharacterData.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterCharacterData.java index 78a4b79263..e5b22216f0 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterCharacterData.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterCharacterData.java @@ -13,20 +13,21 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.spi.BasicJdbcLiteralFormatter; /** - * JdbcLiteralFormatter implementation for handling character data + * {@link org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter} + * implementation for handling character data * * @author Steve Ebersole */ -public class JdbcLiteralFormatterCharacterData extends BasicJdbcLiteralFormatter { +public class JdbcLiteralFormatterCharacterData extends BasicJdbcLiteralFormatter { public static final String NATIONALIZED_PREFIX = "n"; private final boolean isNationalized; - public JdbcLiteralFormatterCharacterData(JavaType javaType) { + public JdbcLiteralFormatterCharacterData(JavaType javaType) { this( javaType, false ); } - public JdbcLiteralFormatterCharacterData(JavaType javaType, boolean isNationalized) { + public JdbcLiteralFormatterCharacterData(JavaType javaType, boolean isNationalized) { super( javaType ); this.isNationalized = isNationalized; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterNumericData.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterNumericData.java index 34ae93215a..50e2b85b69 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterNumericData.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterNumericData.java @@ -13,12 +13,15 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.spi.BasicJdbcLiteralFormatter; /** + * {@link org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter} + * implementation for handling numeric data + * * @author Steve Ebersole */ -public class JdbcLiteralFormatterNumericData extends BasicJdbcLiteralFormatter { +public class JdbcLiteralFormatterNumericData extends BasicJdbcLiteralFormatter { private final Class unwrapJavaType; - public JdbcLiteralFormatterNumericData(JavaType javaType, Class unwrapJavaType) { + public JdbcLiteralFormatterNumericData(JavaType javaType, Class unwrapJavaType) { super( javaType ); this.unwrapJavaType = unwrapJavaType; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterTemporal.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterTemporal.java index cd85076690..8b0b29a761 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterTemporal.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcLiteralFormatterTemporal.java @@ -17,12 +17,15 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.spi.BasicJdbcLiteralFormatter; /** + * {@link org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter} + * implementation for handling date/time literals + * * @author Steve Ebersole */ -public class JdbcLiteralFormatterTemporal extends BasicJdbcLiteralFormatter { +public class JdbcLiteralFormatterTemporal extends BasicJdbcLiteralFormatter { private final TemporalType precision; - public JdbcLiteralFormatterTemporal(JavaType javaType, TemporalType precision) { + public JdbcLiteralFormatterTemporal(JavaType javaType, TemporalType precision) { super( javaType ); this.precision = precision; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcTypeBaseline.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcTypeBaseline.java index 0273ac4ac2..d28a0bd6ec 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcTypeBaseline.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/internal/JdbcTypeBaseline.java @@ -76,7 +76,7 @@ public class JdbcTypeBaseline { target.addDescriptor( ClobJdbcType.DEFAULT ); // Assume `NationalizationSupport#IMPLICIT`. Dialects needing the - // explicit type will map them.. + // explicit type will map them. target.addDescriptor( Types.NCHAR, CharJdbcType.INSTANCE ); target.addDescriptor( Types.NVARCHAR, VarcharJdbcType.INSTANCE ); target.addDescriptor( Types.LONGNVARCHAR, LongVarcharJdbcType.INSTANCE ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/AbstractJdbcLiteralFormatter.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/AbstractJdbcLiteralFormatter.java index 668020d70c..bcf0dc8ba8 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/AbstractJdbcLiteralFormatter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/AbstractJdbcLiteralFormatter.java @@ -10,18 +10,18 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter; /** - * Abstract JdbcLiteralFormatter implementation managing the JavaTypeDescriptor + * Abstract {@link JdbcLiteralFormatter} implementation managing the {@link JavaType} * * @author Steve Ebersole */ -public abstract class AbstractJdbcLiteralFormatter implements JdbcLiteralFormatter { - private final JavaType javaType; +public abstract class AbstractJdbcLiteralFormatter implements JdbcLiteralFormatter { + private final JavaType javaType; - public AbstractJdbcLiteralFormatter(JavaType javaType) { + public AbstractJdbcLiteralFormatter(JavaType javaType) { this.javaType = javaType; } - protected JavaType getJavaType() { + protected JavaType getJavaType() { return javaType; } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/BasicJdbcLiteralFormatter.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/BasicJdbcLiteralFormatter.java index 0e0be993b7..d21161ecb6 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/BasicJdbcLiteralFormatter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/BasicJdbcLiteralFormatter.java @@ -10,12 +10,13 @@ import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.java.JavaType; /** - * Support for JdbcLiteralFormatter implementations with a basic implementation of an unwrap method + * Support for {@link org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter} + * implementations with a basic implementation of an {@link #unwrap} method * * @author Steve Ebersole */ -public abstract class BasicJdbcLiteralFormatter extends AbstractJdbcLiteralFormatter { - public BasicJdbcLiteralFormatter(JavaType javaType) { +public abstract class BasicJdbcLiteralFormatter extends AbstractJdbcLiteralFormatter { + public BasicJdbcLiteralFormatter(JavaType javaType) { super( javaType ); } @@ -29,17 +30,17 @@ public abstract class BasicJdbcLiteralFormatter extends AbstractJdbcLiteralForma } if ( !getJavaType().isInstance( value ) ) { - final Object coerce = getJavaType().coerce( value, wrapperOptions.getSession() ); + final T coerce = getJavaType().coerce( value, wrapperOptions.getSession() ); if ( unwrapType.isInstance( coerce ) ) { return (X) coerce; } - return (X) getJavaType().unwrap( + return getJavaType().unwrap( coerce, unwrapType, wrapperOptions ); } - return (X) getJavaType().unwrap( value, unwrapType, wrapperOptions ); + return getJavaType().unwrap( (T) value, unwrapType, wrapperOptions ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/PayloadWrapperJdbcType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/PayloadWrapperJdbcType.java index d2dfbe4b59..61cc5784ea 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/PayloadWrapperJdbcType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/PayloadWrapperJdbcType.java @@ -47,7 +47,7 @@ public class PayloadWrapperJdbcType implements JdbcType { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { final String valueStr = javaType.unwrap( value, String.class, options ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java index b50e6a9bb3..0a8cd394af 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java @@ -51,15 +51,14 @@ public class QueryParametersValidationArrayTest { @Test public void setParameterWithWrongTypeShouldNotThrowIllegalArgumentException(EntityManagerFactoryScope scope) { scope.inTransaction( - (entityManager) -> { + entityManager -> entityManager.createNativeQuery( "select id " + "from Event " + "where readings = :readings" ) .unwrap( NativeQuery.class ) .setParameter( "readings", new String[]{null, "a"}, StringArrayType.INSTANCE ) - .getResultList(); - } + .getResultList() ); } @@ -104,7 +103,7 @@ public class QueryParametersValidationArrayTest { @Override public ValueBinder getBinder(JavaType javaType) { - return new BasicBinder( javaType, this) { + return new BasicBinder<>( javaType, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { StringArrayTypeDescriptor arrayTypeDescriptor = (StringArrayTypeDescriptor) javaType; @@ -115,8 +114,7 @@ public class QueryParametersValidationArrayTest { } @Override - protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) - throws SQLException { + protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) { throw new UnsupportedOperationException("Binding by name is not supported!"); } }; @@ -124,7 +122,7 @@ public class QueryParametersValidationArrayTest { @Override public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this) { + return new BasicExtractor<>( javaType, this) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { return javaType.wrap( rs.getArray( paramIndex ), options); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/StoredPrefixedStringType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/StoredPrefixedStringType.java index 20714d5a4c..724e6c6602 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/StoredPrefixedStringType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/StoredPrefixedStringType.java @@ -35,7 +35,7 @@ public class StoredPrefixedStringType public static final JdbcType PREFIXED_VARCHAR_TYPE_DESCRIPTOR = new VarcharJdbcType() { public ValueBinder getBinder(final JavaType javaType) { - return new BasicBinder( javaType, this ) { + return new BasicBinder<>( javaType, this ) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { String stringValue = javaType.unwrap( value, String.class, options ); @@ -52,7 +52,7 @@ public class StoredPrefixedStringType } public ValueExtractor getExtractor(final JavaType javaType) { - return new BasicExtractor( javaType, this ) { + return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { String stringValue = rs.getString( paramIndex );