diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/compare/ComparableComparator.java b/hibernate-core/src/main/java/org/hibernate/internal/util/compare/ComparableComparator.java index 6d8a3486e7..5a831ea6cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/compare/ComparableComparator.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/compare/ComparableComparator.java @@ -15,7 +15,9 @@ import java.util.Comparator; * @author Gavin King * @author Steve Ebersole */ +@SuppressWarnings("rawtypes") public class ComparableComparator implements Comparator, Serializable { + public static final Comparator INSTANCE = new ComparableComparator(); @SuppressWarnings("unchecked") diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/compare/RowVersionComparator.java b/hibernate-core/src/main/java/org/hibernate/internal/util/compare/RowVersionComparator.java index 1803f86d88..e313f8c88f 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/compare/RowVersionComparator.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/compare/RowVersionComparator.java @@ -19,13 +19,12 @@ public final class RowVersionComparator implements Comparator { } @Override - @SuppressWarnings("unchecked") public int compare(byte[] o1, byte[] o2) { final int lengthToCheck = Math.min( o1.length, o2.length ); for ( int i = 0 ; i < lengthToCheck ; i++ ) { // must do an unsigned int comparison - final int comparison = ComparableComparator.INSTANCE.compare( + final int comparison = ComparableComparator.instance().compare( Byte.toUnsignedInt( o1[i] ), Byte.toUnsignedInt( o2[i] ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java index 7fd9d2d0d3..e33d204593 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java @@ -836,7 +836,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType }; } else { - return ImmutableMutabilityPlan.INSTANCE; + return ImmutableMutabilityPlan.instance(); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java index 21d7e9999f..676866827b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java @@ -695,7 +695,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme }; } else { - return ImmutableMutabilityPlan.INSTANCE; + return ImmutableMutabilityPlan.instance(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java index a4a67035dd..f7e0b4e07e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java @@ -176,7 +176,7 @@ public class GeneratedValuesProcessor { jdbcSelect, jdbcParamBindings, new NoCallbackExecutionContext( session ), - RowTransformerArrayImpl.INSTANCE, + RowTransformerArrayImpl.instance(), null, FILTER, 1 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java index c1f3ab4c6e..5fbbc33013 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java @@ -438,13 +438,13 @@ public class MappingModelCreationHelper { }; } else { - return ImmutableMutabilityPlan.INSTANCE; + return ImmutableMutabilityPlan.instance(); } } @SuppressWarnings("rawtypes") public static AttributeMetadata getAttributeMetadata(PropertyAccess propertyAccess) { - return new SimpleAttributeMetadata( propertyAccess, ImmutableMutabilityPlan.INSTANCE, false, true, false, false, true, null);// todo (6.0) : not sure if CascadeStyle=null is correct + return new SimpleAttributeMetadata( propertyAccess, ImmutableMutabilityPlan.instance(), false, true, false, false, true, null);// todo (6.0) : not sure if CascadeStyle=null is correct } @SuppressWarnings("rawtypes") diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleAttributeIdentifierMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleAttributeIdentifierMapping.java index f6fad89adc..9adf681b87 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleAttributeIdentifierMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleAttributeIdentifierMapping.java @@ -85,6 +85,6 @@ public interface SingleAttributeIdentifierMapping extends EntityIdentifierMappin @Override default MutabilityPlan getMutabilityPlan() { - return ImmutableMutabilityPlan.INSTANCE; + return ImmutableMutabilityPlan.instance(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java index 8329330e9c..572d1b9ebd 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java @@ -316,7 +316,7 @@ public class MatchingIdSelectionHelper { rowTransformer = RowTransformerSingularReturnImpl.instance(); } else { - rowTransformer = RowTransformerArrayImpl.INSTANCE; + rowTransformer = RowTransformerArrayImpl.instance(); } //noinspection unchecked return jdbcServices.getJdbcSelectExecutor().list( diff --git a/hibernate-core/src/main/java/org/hibernate/result/internal/OutputsImpl.java b/hibernate-core/src/main/java/org/hibernate/result/internal/OutputsImpl.java index 9728d5a4e3..51285b571d 100644 --- a/hibernate-core/src/main/java/org/hibernate/result/internal/OutputsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/result/internal/OutputsImpl.java @@ -188,7 +188,7 @@ public class OutputsImpl implements Outputs { //noinspection unchecked final RowReader rowReader = (RowReader) ResultsHelper.createRowReader( getSessionFactory(), - RowTransformerStandardImpl.INSTANCE, + RowTransformerStandardImpl.instance(), null, jdbcValues ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerArrayImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerArrayImpl.java index fcc5120476..d646707a90 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerArrayImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerArrayImpl.java @@ -17,7 +17,7 @@ public class RowTransformerArrayImpl implements RowTransformer { /** * Singleton access */ - public static final RowTransformerArrayImpl INSTANCE = new RowTransformerArrayImpl(); + private static final RowTransformerArrayImpl INSTANCE = new RowTransformerArrayImpl(); public static RowTransformerArrayImpl instance() { return INSTANCE; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerListImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerListImpl.java index 98b09664a8..47fe3decbd 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerListImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerListImpl.java @@ -19,9 +19,11 @@ public class RowTransformerListImpl implements RowTransformer> { /** * Singleton access */ - public static final RowTransformerListImpl INSTANCE = new RowTransformerListImpl(); + @SuppressWarnings( "rawtypes" ) + private static final RowTransformerListImpl INSTANCE = new RowTransformerListImpl(); - public static RowTransformerListImpl instance() { + @SuppressWarnings( "unchecked" ) + public static RowTransformerListImpl instance() { return INSTANCE; } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerSingularReturnImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerSingularReturnImpl.java index 434243ee22..aab993aad8 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerSingularReturnImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerSingularReturnImpl.java @@ -22,7 +22,7 @@ public class RowTransformerSingularReturnImpl implements RowTransformer { * Singleton access */ @SuppressWarnings("rawtypes") - public static final RowTransformerSingularReturnImpl INSTANCE = new RowTransformerSingularReturnImpl(); + private static final RowTransformerSingularReturnImpl INSTANCE = new RowTransformerSingularReturnImpl(); @SuppressWarnings("unchecked") public static RowTransformer instance() { diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerStandardImpl.java index 528bbe5864..1c23add162 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerStandardImpl.java @@ -22,7 +22,7 @@ public class RowTransformerStandardImpl implements RowTransformer { * Singleton access */ @SuppressWarnings("rawtypes") - public static final RowTransformerStandardImpl INSTANCE = new RowTransformerStandardImpl(); + private static final RowTransformerStandardImpl INSTANCE = new RowTransformerStandardImpl(); @SuppressWarnings("unchecked") public static RowTransformer instance() { diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java index 77839c03d8..e94898dc2c 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java @@ -73,9 +73,9 @@ public class StandardRowReader implements RowReader { this.sortedForResolveInstance = (Initializer[]) sortedForResolveInitializers; this.sortedForResolveInstanceData = new InitializerData[sortedForResolveInstance.length]; this.hasCollectionInitializers = hasCollectionInitializers; - this.rowTransformer = rowTransformer == RowTransformerArrayImpl.INSTANCE && resultAssemblers.length != 1 - || rowTransformer == RowTransformerStandardImpl.INSTANCE - || rowTransformer == RowTransformerSingularReturnImpl.INSTANCE && resultAssemblers.length == 1 + this.rowTransformer = rowTransformer == RowTransformerArrayImpl.instance() && resultAssemblers.length != 1 + || rowTransformer == RowTransformerStandardImpl.instance() + || rowTransformer == RowTransformerSingularReturnImpl.instance() && resultAssemblers.length == 1 ? null : rowTransformer; this.domainResultJavaType = domainResultJavaType; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java index 7100efeb4d..442a0d9c16 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java @@ -26,7 +26,11 @@ import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl; public class ScrollableResultsConsumer implements ResultsConsumer, R> { /** * Singleton access to the standard scrollable-results consumer instance + * + * @deprecated in favor of {@link #instance()} */ + @SuppressWarnings( "rawtypes" ) + @Deprecated( forRemoval = true ) public static final ScrollableResultsConsumer INSTANCE = new ScrollableResultsConsumer(); @SuppressWarnings("unchecked") diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/SingleResultConsumer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/SingleResultConsumer.java index b0f4dfd1bd..0003a9b329 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/SingleResultConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/SingleResultConsumer.java @@ -27,8 +27,8 @@ public class SingleResultConsumer implements ResultsConsumer { private static final SingleResultConsumer INSTANCE = new SingleResultConsumer<>(); + @SuppressWarnings( "unchecked" ) public static SingleResultConsumer instance() { - //noinspection unchecked return (SingleResultConsumer) INSTANCE; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractClassJavaType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractClassJavaType.java index 219070caf4..d44cb4cb9c 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractClassJavaType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractClassJavaType.java @@ -46,13 +46,12 @@ public abstract class AbstractClassJavaType implements BasicJavaType, Seri * @param type The Java type. * @param mutabilityPlan The plan for handling mutability aspects of the java type. */ - @SuppressWarnings("unchecked") protected AbstractClassJavaType(Class type, MutabilityPlan mutabilityPlan) { this( type, mutabilityPlan, Comparable.class.isAssignableFrom( type ) - ? (Comparator) ComparableComparator.INSTANCE + ? ComparableComparator.instance() : null ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/Immutability.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/Immutability.java index 45f3a1f4d4..3bba6c66d9 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/Immutability.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/Immutability.java @@ -22,7 +22,10 @@ import org.hibernate.annotations.Mutability; public class Immutability implements MutabilityPlan { /** * Singleton access + * + * @deprecated in favor of {@link #instance()} */ + @Deprecated( forRemoval = true ) public static final Immutability INSTANCE = new Immutability(); public static MutabilityPlan instance() { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ImmutableMutabilityPlan.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ImmutableMutabilityPlan.java index b475340471..bbec2228ea 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ImmutableMutabilityPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ImmutableMutabilityPlan.java @@ -21,6 +21,14 @@ import org.hibernate.SharedSessionContract; * @author Steve Ebersole */ public class ImmutableMutabilityPlan implements MutabilityPlan { + + /** + * Singleton access + * + * @deprecated in favor of {@link #instance()} + */ + @SuppressWarnings( "rawtypes" ) + @Deprecated( forRemoval = true ) public static final ImmutableMutabilityPlan INSTANCE = new ImmutableMutabilityPlan(); public static ImmutableMutabilityPlan instance() {