diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java index 7cb4c6972701..6ad0b85d6d75 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java @@ -95,16 +95,16 @@ private void collectAttributeConversionInfo(Map // collect superclass info first collectAttributeConversionInfo( infoMap, entityClassDetails.getSuperClass() ); - final var sourceModelContext = getSourceModelContext(); + final var modelContext = getSourceModelContext(); final boolean canContainConvert = - entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, sourceModelContext ) - || entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, sourceModelContext ) - || entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, sourceModelContext ); + entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, modelContext ) + || entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, modelContext ) + || entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, modelContext ); if ( ! canContainConvert ) { return; } - entityClassDetails.forEachAnnotationUsage( Convert.class, sourceModelContext, (usage) -> { + entityClassDetails.forEachAnnotationUsage( Convert.class, modelContext, (usage) -> { final var info = new AttributeConversionInfo( usage, entityClassDetails ); if ( isEmpty( info.getAttributeName() ) ) { throw new IllegalStateException( "@Convert placed on @Entity/@MappedSuperclass must define attributeName" ); @@ -120,9 +120,11 @@ public void startingProperty(MemberDetails property) { if ( !attributeConversionInfoMap.containsKey( propertyName ) ) { property.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> { final var info = new AttributeConversionInfo( usage, property ); - final String path = isEmpty( info.getAttributeName() ) - ? propertyName - : propertyName + '.' + info.getAttributeName(); + final String infoAttributeName = info.getAttributeName(); + final String path = + isEmpty( infoAttributeName ) + ? propertyName + : propertyName + '.' + infoAttributeName; attributeConversionInfoMap.put( path, info ); } ); } @@ -166,7 +168,7 @@ public void addProperty(Property prop, MemberDetails memberDetails, ClassDetails //TODO handle quote and non quote table comparison final String tableName = prop.getValue().getTable().getName(); if ( getJoinsPerRealTableName().containsKey( tableName ) ) { - final Join join = getJoinsPerRealTableName().get( tableName ); + final var join = getJoinsPerRealTableName().get( tableName ); addPropertyToJoin( prop, memberDetails, declaringClass, join ); } else { @@ -180,14 +182,14 @@ public void addProperty(Property prop, MemberDetails memberDetails, ClassDetails @Override public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) { - final Join join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation ); + final var join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation ); joins = entityBinder.getSecondaryTables(); return join; } @Override public Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation) { - final Join join = entityBinder.createJoin( + final var join = entityBinder.createJoin( this, noDelayInPkColumnCreation, false, @@ -289,10 +291,10 @@ static void prepareActualProperty( } // If the property depends on a type variable, we have to copy it and the Value - final Property actualProperty = property.copy(); + final var actualProperty = property.copy(); actualProperty.setGeneric( true ); actualProperty.setReturnedClassName( memberDetails.getType().getName() ); - final Value value = actualProperty.getValue().copy(); + final var value = actualProperty.getValue().copy(); if ( value instanceof Collection collection ) { if ( !allowCollections ) { throw new AssertionFailure( "Collections are not allowed as identifier properties" ); @@ -301,13 +303,13 @@ static void prepareActualProperty( // collection.setOwner( null ); collection.setRole( memberDetails.getDeclaringType().getName() + "." + property.getName() ); // To copy the element and key values, we need to defer setting the type name until the CollectionBinder ran - final Value originalValue = property.getValue(); + final var originalValue = property.getValue(); context.getMetadataCollector().addSecondPass( new SecondPass() { @Override public void doSecondPass(Map persistentClasses) { final var initializedCollection = (Collection) originalValue; - final Value element = initializedCollection.getElement().copy(); + final var element = initializedCollection.getElement().copy(); setTypeName( element, memberDetails.getElementType().getName() ); if ( initializedCollection instanceof IndexedCollection indexedCollection ) { final Value index = indexedCollection.getIndex().copy(); diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/IdentifiableTypeClass.java b/hibernate-core/src/main/java/org/hibernate/mapping/IdentifiableTypeClass.java index f06e5cdbc082..ef3a0211018b 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/IdentifiableTypeClass.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/IdentifiableTypeClass.java @@ -20,5 +20,9 @@ public interface IdentifiableTypeClass extends TableContainer { Table getImplicitTable(); + /** + * @deprecated No longer used + */ + @Deprecated(since = "7.2", forRemoval = true) void applyProperty(Property property); } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java index 5bcc55f9c3cb..c0e0a879b347 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java @@ -67,16 +67,15 @@ public List getDeclaredProperties() { return declaredProperties; } - public void addDeclaredProperty(Property p) { + public void addDeclaredProperty(Property property) { //Do not add duplicate properties - //TODO is it efficient enough? - String name = p.getName(); + final String name = property.getName(); for ( var declaredProperty : declaredProperties ) { if ( name.equals( declaredProperty.getName() ) ) { return; } } - declaredProperties.add(p); + declaredProperties.add( property ); } public Class getMappedClass() { @@ -141,7 +140,7 @@ public Component getIdentifierMapper() { if ( superMappedSuperclass != null ) { propagatedMapper = superMappedSuperclass.getIdentifierMapper(); } - if (propagatedMapper == null && superPersistentClass != null){ + if ( propagatedMapper == null && superPersistentClass != null ) { propagatedMapper = superPersistentClass.getIdentifierMapper(); } } @@ -183,8 +182,8 @@ public boolean hasProperty(String name) { */ public boolean isPropertyDefinedInHierarchy(String name) { return hasProperty( name ) - || getSuperMappedSuperclass() != null && getSuperMappedSuperclass().isPropertyDefinedInHierarchy( name ) - || getSuperPersistentClass() != null && getSuperPersistentClass().isPropertyDefinedInHierarchy( name ); + || superMappedSuperclass != null && superMappedSuperclass.isPropertyDefinedInHierarchy( name ) + || superPersistentClass != null && superPersistentClass.isPropertyDefinedInHierarchy( name ); } public void prepareForMappingModel() { @@ -228,7 +227,7 @@ public Table getImplicitTable() { return implicitTable; } - @Override + @Override @Deprecated(forRemoval = true) public void applyProperty(Property property) { assert property.getValue().getTable() != null && property.getValue().getTable().equals( getImplicitTable() ); diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java index aa77cda969c8..608f01064b98 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java @@ -1145,7 +1145,7 @@ public List getSubTypes() { throw new UnsupportedOperationException( "Not implemented yet" ); } - @Override + @Override @Deprecated(forRemoval = true) public void applyProperty(Property property) { final var table = property.getValue().getTable(); if ( table.equals( getImplicitTable() ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index fd344893354c..4cabe13f4194 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -866,18 +866,12 @@ public boolean hasAnyUpdatableColumns() { @Override public boolean isColumnInsertable(int index) { - if ( !insertability.isEmpty() ) { - return insertability.get( index ); - } - return false; + return !insertability.isEmpty() && insertability.get( index ); } @Override public boolean isColumnUpdateable(int index) { - if ( !updatability.isEmpty() ) { - return updatability.get( index ); - } - return false; + return !updatability.isEmpty() && updatability.get( index ); } public boolean isPartitionKey() {