squash warnings

This commit is contained in:
Gavin King 2024-09-22 22:27:31 +02:00
parent 600288d1bb
commit efc50aad00
1 changed files with 18 additions and 29 deletions

View File

@ -107,9 +107,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
); );
} }
if ( hbmValueMapping instanceof JaxbHbmNativeQueryReturnType ) { if ( hbmValueMapping instanceof JaxbHbmNativeQueryReturnType hbmEntityReturn ) {
final JaxbHbmNativeQueryReturnType hbmEntityReturn = (JaxbHbmNativeQueryReturnType) hbmValueMapping;
final EntityResultDescriptor entityResultDescriptor = new EntityResultDescriptor( final EntityResultDescriptor entityResultDescriptor = new EntityResultDescriptor(
hbmEntityReturn, hbmEntityReturn,
() -> joinDescriptors, () -> joinDescriptors,
@ -119,10 +117,8 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
localResultDescriptors.add( entityResultDescriptor ); localResultDescriptors.add( entityResultDescriptor );
fetchParentByAlias.put( entityResultDescriptor.tableAlias, entityResultDescriptor ); fetchParentByAlias.put( entityResultDescriptor.tableAlias, entityResultDescriptor );
} }
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryCollectionLoadReturnType ) { else if ( hbmValueMapping instanceof JaxbHbmNativeQueryCollectionLoadReturnType hbmCollectionReturn ) {
final JaxbHbmNativeQueryCollectionLoadReturnType hbmCollectionReturn = (JaxbHbmNativeQueryCollectionLoadReturnType) hbmValueMapping;
foundCollectionReturn = true; foundCollectionReturn = true;
final CollectionResultDescriptor collectionResultDescriptor = new CollectionResultDescriptor( final CollectionResultDescriptor collectionResultDescriptor = new CollectionResultDescriptor(
hbmCollectionReturn, hbmCollectionReturn,
() -> joinDescriptors, () -> joinDescriptors,
@ -132,14 +128,10 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
localResultDescriptors.add( collectionResultDescriptor ); localResultDescriptors.add( collectionResultDescriptor );
fetchParentByAlias.put( collectionResultDescriptor.tableAlias, collectionResultDescriptor ); fetchParentByAlias.put( collectionResultDescriptor.tableAlias, collectionResultDescriptor );
} }
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryJoinReturnType ) { else if ( hbmValueMapping instanceof JaxbHbmNativeQueryJoinReturnType jaxbHbmJoinReturn ) {
final JaxbHbmNativeQueryJoinReturnType jaxbHbmJoinReturn = (JaxbHbmNativeQueryJoinReturnType) hbmValueMapping;
collectJoinFetch( jaxbHbmJoinReturn, joinDescriptors, fetchParentByAlias, registrationName, context ); collectJoinFetch( jaxbHbmJoinReturn, joinDescriptors, fetchParentByAlias, registrationName, context );
} }
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryScalarReturnType ) { else if ( hbmValueMapping instanceof JaxbHbmNativeQueryScalarReturnType hbmScalarReturn ) {
final JaxbHbmNativeQueryScalarReturnType hbmScalarReturn = (JaxbHbmNativeQueryScalarReturnType) hbmValueMapping;
localResultDescriptors.add( new ScalarDescriptor( hbmScalarReturn ) ); localResultDescriptors.add( new ScalarDescriptor( hbmScalarReturn ) );
} }
else { else {
@ -510,7 +502,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
this.parent = parent; this.parent = parent;
this.propertyPath = hbmPropertyMapping.getName(); this.propertyPath = hbmPropertyMapping.getName();
this.propertyPathParts = StringHelper.split( ".", propertyPath ); this.propertyPathParts = StringHelper.split( ".", propertyPath );
this.columnAliases = extractColumnAliases( hbmPropertyMapping, context ); this.columnAliases = extractColumnAliases( hbmPropertyMapping );
if ( columnAliases.size() > 1 ) { if ( columnAliases.size() > 1 ) {
// We have to reorder the columns according to the property reordering // We have to reorder the columns according to the property reordering
@ -536,11 +528,11 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
} }
private static Value getValue(HbmFetchParent parent, String propertyPath, MetadataBuildingContext context) { private static Value getValue(HbmFetchParent parent, String propertyPath, MetadataBuildingContext context) {
if ( parent instanceof EntityResultDescriptor ) { if ( parent instanceof EntityResultDescriptor resultDescriptor ) {
final PersistentClass entityBinding = context.getMetadataCollector() final PersistentClass entityBinding = context.getMetadataCollector()
.getEntityBinding( ( (EntityResultDescriptor) parent ).entityName ); .getEntityBinding( resultDescriptor.entityName );
Value value = null; Value value = null;
StringTokenizer st = new StringTokenizer( propertyPath, ".", false ); final StringTokenizer st = new StringTokenizer( propertyPath, ".", false );
try { try {
while ( st.hasMoreElements() ) { while ( st.hasMoreElements() ) {
final String element = (String) st.nextElement(); final String element = (String) st.nextElement();
@ -569,17 +561,17 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
value = entityBinding.getProperty( element ).getValue(); value = entityBinding.getProperty( element ).getValue();
} }
} }
else if ( value instanceof Component ) { else if ( value instanceof Component component ) {
value = ( (Component) value ).getProperty( element ).getValue(); value = component.getProperty( element ).getValue();
} }
else if ( value instanceof ToOne ) { else if ( value instanceof ToOne toOne ) {
value = context.getMetadataCollector() value = context.getMetadataCollector()
.getEntityBinding( ( (ToOne) value ).getReferencedEntityName() ) .getEntityBinding( toOne.getReferencedEntityName() )
.getProperty( element ) .getProperty( element )
.getValue(); .getValue();
} }
else if ( value instanceof OneToMany ) { else if ( value instanceof OneToMany oneToMany ) {
value = ( (OneToMany) value ).getAssociatedClass().getProperty( element ).getValue(); value = oneToMany.getAssociatedClass().getProperty( element ).getValue();
} }
else { else {
final Collection collection = (Collection) value; final Collection collection = (Collection) value;
@ -606,9 +598,9 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
throw new MappingException( "property [" + propertyPath + "] not found on entity [" + entityBinding.getEntityName() + "]" ); throw new MappingException( "property [" + propertyPath + "] not found on entity [" + entityBinding.getEntityName() + "]" );
} }
} }
else if ( parent instanceof CollectionResultDescriptor ) { else if ( parent instanceof CollectionResultDescriptor descriptor ) {
final Collection collectionBinding = context.getMetadataCollector() final Collection collectionBinding = context.getMetadataCollector()
.getCollectionBinding( ( (CollectionResultDescriptor) parent ).collectionPath.getFullPath() ); .getCollectionBinding( descriptor.collectionPath.getFullPath() );
return collectionBinding.getElement(); return collectionBinding.getElement();
} }
else { else {
@ -629,9 +621,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
return columnAliases; return columnAliases;
} }
private static List<String> extractColumnAliases( private static List<String> extractColumnAliases(JaxbHbmNativeQueryPropertyReturnType hbmPropertyMapping) {
JaxbHbmNativeQueryPropertyReturnType hbmPropertyMapping,
MetadataBuildingContext context) {
if ( hbmPropertyMapping.getColumn() != null ) { if ( hbmPropertyMapping.getColumn() != null ) {
return Collections.singletonList( hbmPropertyMapping.getColumn() ); return Collections.singletonList( hbmPropertyMapping.getColumn() );
} }
@ -853,7 +843,6 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
public static class CollectionResultDescriptor implements ResultDescriptor, HbmFetchParent { public static class CollectionResultDescriptor implements ResultDescriptor, HbmFetchParent {
private final NavigablePath collectionPath; private final NavigablePath collectionPath;
private final String tableAlias; private final String tableAlias;
private final LockMode lockMode;
private final Supplier<Map<String, Map<String, JoinDescriptor>>> joinDescriptorsAccess; private final Supplier<Map<String, Map<String, JoinDescriptor>>> joinDescriptorsAccess;
private final List<HbmFetchDescriptor> propertyFetchDescriptors; private final List<HbmFetchDescriptor> propertyFetchDescriptors;
@ -887,7 +876,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
collectionPath collectionPath
); );
this.lockMode = hbmCollectionReturn.getLockMode(); // this.lockMode = hbmCollectionReturn.getLockMode();
this.joinDescriptorsAccess = joinDescriptorsAccess; this.joinDescriptorsAccess = joinDescriptorsAccess;
this.propertyFetchDescriptors = extractPropertyFetchDescriptors( this.propertyFetchDescriptors = extractPropertyFetchDescriptors(