From 66776f6b7819ccc7b9141021e52cf796ca20c35c Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 29 Oct 2022 00:29:18 +0200 Subject: [PATCH] simplify a method --- .../InFlightMetadataCollectorImpl.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java index 24c28d61e9..3ec8ebcf4f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java @@ -1009,8 +1009,8 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector */ private class TableColumnNameBinding implements Serializable { private final String tableName; - private Map logicalToPhysical = new HashMap<>(); - private Map physicalToLogical = new HashMap<>(); + private final Map logicalToPhysical = new HashMap<>(); + private final Map physicalToLogical = new HashMap<>(); private TableColumnNameBinding(String tableName) { this.tableName = tableName; @@ -1105,14 +1105,12 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector } Table currentTable = table; - String physicalName = null; - while ( currentTable != null ) { final TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable ); if ( binding != null ) { - physicalName = binding.logicalToPhysical.get( logicalName ); + final String physicalName = binding.logicalToPhysical.get( logicalName ); if ( physicalName != null ) { - break; + return physicalName; } } @@ -1124,12 +1122,8 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector } } - if ( physicalName == null ) { - throw new MappingException( - "Unable to find column with logical name " + logicalName.render() + " in table " + table.getName() - ); - } - return physicalName; + throw new MappingException( "Unable to find column with logical name " + logicalName.render() + + " in table " + table.getName() ); } @Override