@@ -190,11 +190,10 @@ public void registerEntityType(PersistentClass persistentClass, EntityTypeImpl<
190190 public void registerEmbeddableType (
191191 EmbeddableDomainType <?> embeddableType ,
192192 Component bootDescriptor ) {
193- assert embeddableType .getJavaType () != null ;
194- assert ! Map .class .isAssignableFrom ( embeddableType .getJavaType () );
195-
196- embeddablesToProcess
197- .computeIfAbsent ( embeddableType .getJavaType (), k -> new ArrayList <>( 1 ) )
193+ final var javaType = embeddableType .getJavaType ();
194+ assert javaType != null ;
195+ assert !Map .class .isAssignableFrom ( javaType );
196+ embeddablesToProcess .computeIfAbsent ( javaType , k -> new ArrayList <>( 1 ) )
198197 .add ( embeddableType );
199198 registerComponentByEmbeddable ( embeddableType , bootDescriptor );
200199 }
@@ -254,9 +253,8 @@ public EntityDomainType<?> locateEntityType(Class<?> javaType) {
254253 *
255254 * @return The corresponding JPA {@link org.hibernate.type.EntityType}, or null.
256255 */
257- @ SuppressWarnings ("unchecked" )
258- public <E > IdentifiableDomainType <E > locateIdentifiableType (String entityName ) {
259- return (IdentifiableDomainType <E >) identifiableTypesByName .get ( entityName );
256+ public IdentifiableDomainType <?> locateIdentifiableType (String entityName ) {
257+ return identifiableTypesByName .get ( entityName );
260258 }
261259
262260 public Map <String , IdentifiableDomainType <?>> getIdentifiableTypesByName () {
@@ -298,31 +296,30 @@ public void wrapUp() {
298296 }
299297
300298 final boolean staticMetamodelScanEnabled =
301- this . jpaStaticMetaModelPopulationSetting != JpaStaticMetamodelPopulationSetting .DISABLED ;
299+ jpaStaticMetaModelPopulationSetting != JpaStaticMetamodelPopulationSetting .DISABLED ;
302300 final Set <String > processedMetamodelClasses = new HashSet <>();
303301
304302 //we need to process types from superclasses to subclasses
305303 for ( Object mapping : orderedMappings ) {
306- if ( PersistentClass .class .isAssignableFrom ( mapping .getClass () ) ) {
307- final PersistentClass safeMapping = (PersistentClass ) mapping ;
304+ if ( mapping instanceof PersistentClass persistentClass ) {
308305 if ( log .isTraceEnabled () ) {
309- log .trace ( "Starting entity [" + safeMapping .getEntityName () + ']' );
306+ log .trace ( "Starting entity [" + persistentClass .getEntityName () + ']' );
310307 }
311308 try {
312- final EntityDomainType <?> jpaMapping = entityTypesByPersistentClass .get ( safeMapping );
309+ final var jpaMapping = entityTypesByPersistentClass .get ( persistentClass );
313310
314- applyIdMetadata ( safeMapping , jpaMapping );
315- applyVersionAttribute ( safeMapping , jpaMapping );
316- applyGenericProperties ( safeMapping , jpaMapping );
311+ applyIdMetadata ( persistentClass , jpaMapping );
312+ applyVersionAttribute ( persistentClass , jpaMapping );
313+ applyGenericProperties ( persistentClass , jpaMapping );
317314
318- for ( Property property : safeMapping .getDeclaredProperties () ) {
319- if ( property .getValue () == safeMapping .getIdentifierMapper () ) {
315+ for ( Property property : persistentClass .getDeclaredProperties () ) {
316+ if ( property .getValue () == persistentClass .getIdentifierMapper () ) {
320317 // property represents special handling for id-class mappings but we have already
321318 // accounted for the embedded property mappings in #applyIdMetadata &&
322319 // #buildIdClassAttributes
323320 continue ;
324321 }
325- if ( safeMapping .isVersioned () && property == safeMapping .getVersion () ) {
322+ if ( persistentClass .isVersioned () && property == persistentClass .getVersion () ) {
326323 // skip the version property, it was already handled previously.
327324 continue ;
328325 }
@@ -337,30 +334,29 @@ public void wrapUp() {
337334 }
338335 finally {
339336 if ( log .isTraceEnabled () ) {
340- log .trace ( "Completed entity [" + safeMapping .getEntityName () + ']' );
337+ log .trace ( "Completed entity [" + persistentClass .getEntityName () + ']' );
341338 }
342339 }
343340 }
344- else if ( MappedSuperclass .class .isAssignableFrom ( mapping .getClass () ) ) {
345- final MappedSuperclass safeMapping = (MappedSuperclass ) mapping ;
341+ else if ( mapping instanceof MappedSuperclass mappedSuperclass ) {
346342 if ( log .isTraceEnabled () ) {
347- log .trace ( "Starting mapped superclass [" + safeMapping .getMappedClass ().getName () + ']' );
343+ log .trace ( "Starting mapped superclass [" + mappedSuperclass .getMappedClass ().getName () + ']' );
348344 }
349345 try {
350- final var jpaType = mappedSuperclassByMappedSuperclassMapping .get ( safeMapping );
346+ final var jpaType = mappedSuperclassByMappedSuperclassMapping .get ( mappedSuperclass );
351347
352- applyIdMetadata ( safeMapping , jpaType );
353- applyVersionAttribute ( safeMapping , jpaType );
348+ applyIdMetadata ( mappedSuperclass , jpaType );
349+ applyVersionAttribute ( mappedSuperclass , jpaType );
354350// applyNaturalIdAttribute( safeMapping, jpaType );
355351
356- for ( Property property : safeMapping .getDeclaredProperties () ) {
357- if ( isIdentifierProperty ( property , safeMapping ) ) {
352+ for ( Property property : mappedSuperclass .getDeclaredProperties () ) {
353+ if ( isIdentifierProperty ( property , mappedSuperclass ) ) {
358354 // property represents special handling for id-class mappings but we have already
359355 // accounted for the embedded property mappings in #applyIdMetadata &&
360356 // #buildIdClassAttributes
361357 continue ;
362358 }
363- else if ( safeMapping .isVersioned () && property == safeMapping .getVersion () ) {
359+ else if ( mappedSuperclass .isVersioned () && property == mappedSuperclass .getVersion () ) {
364360 // skip the version property, it was already handled previously.
365361 continue ;
366362 }
@@ -375,7 +371,7 @@ else if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
375371 }
376372 finally {
377373 if ( log .isTraceEnabled () ) {
378- log .trace ( "Completed mapped superclass [" + safeMapping .getMappedClass ().getName () + ']' );
374+ log .trace ( "Completed mapped superclass [" + mappedSuperclass .getMappedClass ().getName () + ']' );
379375 }
380376 }
381377 }
0 commit comments