Skip to content

Commit 7bb0292

Browse files
committed
deprecate an obsolete method
1 parent 3525545 commit 7bb0292

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ private void collectAttributeConversionInfo(Map<String, AttributeConversionInfo>
9595
// collect superclass info first
9696
collectAttributeConversionInfo( infoMap, entityClassDetails.getSuperClass() );
9797

98-
final var sourceModelContext = getSourceModelContext();
98+
final var modelContext = getSourceModelContext();
9999
final boolean canContainConvert =
100-
entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, sourceModelContext )
101-
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, sourceModelContext )
102-
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, sourceModelContext );
100+
entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, modelContext )
101+
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, modelContext )
102+
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, modelContext );
103103
if ( ! canContainConvert ) {
104104
return;
105105
}
106106

107-
entityClassDetails.forEachAnnotationUsage( Convert.class, sourceModelContext, (usage) -> {
107+
entityClassDetails.forEachAnnotationUsage( Convert.class, modelContext, (usage) -> {
108108
final var info = new AttributeConversionInfo( usage, entityClassDetails );
109109
if ( isEmpty( info.getAttributeName() ) ) {
110110
throw new IllegalStateException( "@Convert placed on @Entity/@MappedSuperclass must define attributeName" );
@@ -120,9 +120,11 @@ public void startingProperty(MemberDetails property) {
120120
if ( !attributeConversionInfoMap.containsKey( propertyName ) ) {
121121
property.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
122122
final var info = new AttributeConversionInfo( usage, property );
123-
final String path = isEmpty( info.getAttributeName() )
124-
? propertyName
125-
: propertyName + '.' + info.getAttributeName();
123+
final String infoAttributeName = info.getAttributeName();
124+
final String path =
125+
isEmpty( infoAttributeName )
126+
? propertyName
127+
: propertyName + '.' + infoAttributeName;
126128
attributeConversionInfoMap.put( path, info );
127129
} );
128130
}
@@ -166,7 +168,7 @@ public void addProperty(Property prop, MemberDetails memberDetails, ClassDetails
166168
//TODO handle quote and non quote table comparison
167169
final String tableName = prop.getValue().getTable().getName();
168170
if ( getJoinsPerRealTableName().containsKey( tableName ) ) {
169-
final Join join = getJoinsPerRealTableName().get( tableName );
171+
final var join = getJoinsPerRealTableName().get( tableName );
170172
addPropertyToJoin( prop, memberDetails, declaringClass, join );
171173
}
172174
else {
@@ -180,14 +182,14 @@ public void addProperty(Property prop, MemberDetails memberDetails, ClassDetails
180182

181183
@Override
182184
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
183-
final Join join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation );
185+
final var join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation );
184186
joins = entityBinder.getSecondaryTables();
185187
return join;
186188
}
187189

188190
@Override
189191
public Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation) {
190-
final Join join = entityBinder.createJoin(
192+
final var join = entityBinder.createJoin(
191193
this,
192194
noDelayInPkColumnCreation,
193195
false,
@@ -289,10 +291,10 @@ static void prepareActualProperty(
289291
}
290292

291293
// If the property depends on a type variable, we have to copy it and the Value
292-
final Property actualProperty = property.copy();
294+
final var actualProperty = property.copy();
293295
actualProperty.setGeneric( true );
294296
actualProperty.setReturnedClassName( memberDetails.getType().getName() );
295-
final Value value = actualProperty.getValue().copy();
297+
final var value = actualProperty.getValue().copy();
296298
if ( value instanceof Collection collection ) {
297299
if ( !allowCollections ) {
298300
throw new AssertionFailure( "Collections are not allowed as identifier properties" );
@@ -301,13 +303,13 @@ static void prepareActualProperty(
301303
// collection.setOwner( null );
302304
collection.setRole( memberDetails.getDeclaringType().getName() + "." + property.getName() );
303305
// To copy the element and key values, we need to defer setting the type name until the CollectionBinder ran
304-
final Value originalValue = property.getValue();
306+
final var originalValue = property.getValue();
305307
context.getMetadataCollector().addSecondPass(
306308
new SecondPass() {
307309
@Override
308310
public void doSecondPass(Map<String, PersistentClass> persistentClasses) {
309311
final var initializedCollection = (Collection) originalValue;
310-
final Value element = initializedCollection.getElement().copy();
312+
final var element = initializedCollection.getElement().copy();
311313
setTypeName( element, memberDetails.getElementType().getName() );
312314
if ( initializedCollection instanceof IndexedCollection indexedCollection ) {
313315
final Value index = indexedCollection.getIndex().copy();

hibernate-core/src/main/java/org/hibernate/mapping/IdentifiableTypeClass.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ public interface IdentifiableTypeClass extends TableContainer {
2020

2121
Table getImplicitTable();
2222

23+
/**
24+
* @deprecated No longer used
25+
*/
26+
@Deprecated(since = "7.2", forRemoval = true)
2327
void applyProperty(Property property);
2428
}

hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ public List<Property> getDeclaredProperties() {
6767
return declaredProperties;
6868
}
6969

70-
public void addDeclaredProperty(Property p) {
70+
public void addDeclaredProperty(Property property) {
7171
//Do not add duplicate properties
72-
//TODO is it efficient enough?
73-
String name = p.getName();
72+
final String name = property.getName();
7473
for ( var declaredProperty : declaredProperties ) {
7574
if ( name.equals( declaredProperty.getName() ) ) {
7675
return;
7776
}
7877
}
79-
declaredProperties.add(p);
78+
declaredProperties.add( property );
8079
}
8180

8281
public Class<?> getMappedClass() {
@@ -141,7 +140,7 @@ public Component getIdentifierMapper() {
141140
if ( superMappedSuperclass != null ) {
142141
propagatedMapper = superMappedSuperclass.getIdentifierMapper();
143142
}
144-
if (propagatedMapper == null && superPersistentClass != null){
143+
if ( propagatedMapper == null && superPersistentClass != null ) {
145144
propagatedMapper = superPersistentClass.getIdentifierMapper();
146145
}
147146
}
@@ -183,8 +182,8 @@ public boolean hasProperty(String name) {
183182
*/
184183
public boolean isPropertyDefinedInHierarchy(String name) {
185184
return hasProperty( name )
186-
|| getSuperMappedSuperclass() != null && getSuperMappedSuperclass().isPropertyDefinedInHierarchy( name )
187-
|| getSuperPersistentClass() != null && getSuperPersistentClass().isPropertyDefinedInHierarchy( name );
185+
|| superMappedSuperclass != null && superMappedSuperclass.isPropertyDefinedInHierarchy( name )
186+
|| superPersistentClass != null && superPersistentClass.isPropertyDefinedInHierarchy( name );
188187
}
189188

190189
public void prepareForMappingModel() {
@@ -228,7 +227,7 @@ public Table getImplicitTable() {
228227
return implicitTable;
229228
}
230229

231-
@Override
230+
@Override @Deprecated(forRemoval = true)
232231
public void applyProperty(Property property) {
233232
assert property.getValue().getTable() != null
234233
&& property.getValue().getTable().equals( getImplicitTable() );

hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ public List<IdentifiableTypeClass> getSubTypes() {
11451145
throw new UnsupportedOperationException( "Not implemented yet" );
11461146
}
11471147

1148-
@Override
1148+
@Override @Deprecated(forRemoval = true)
11491149
public void applyProperty(Property property) {
11501150
final var table = property.getValue().getTable();
11511151
if ( table.equals( getImplicitTable() ) ) {

0 commit comments

Comments
 (0)