logicalName = logicalName.toLowerCase(); String finalName = null; Table currentTable = table; do { ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable); if (binding != null) { finalName = (String) binding.logicalToPhysical.get( logicalName ); } String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() ); TableDescription description = (TableDescription) tableNameBinding.get(key); if (description != null) currentTable = description.denormalizedSupertable; } while (finalName == null && currentTable != null); if (finalName == null) { throw new MappingException( "Unable to find column with logical name " + logicalName + " in table " + table.getName() ); } return finalName;
String logical = null; Table currentTable = table; TableDescription description = null; do { ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable); if (binding != null) { logical = (String) binding.physicalToLogical.get( physicalName ); } String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() ); description = (TableDescription) tableNameBinding.get(key); if (description != null) currentTable = description.denormalizedSupertable; } while (logical == null && currentTable != null && description != null); if (logical == null) { throw new MappingException( "Unable to find logical column name from physical name " + physicalName + " in table " + table.getName() ); } return logical;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/Mappings.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/Mappings.java
Method name: String getPhysicalColumnName(String, Table) Method name: String getLogicalColumnName(String, Table)
Number of AST nodes: 14 Number of AST nodes: 14
1
logicalName = logicalName.toLowerCase();
1
String logical
2
		String finalName = null;
2
 = null;
3
		Table currentTable = table;
3
		Table currentTable = table;
4
		
4
		TableDescription description = null;
5
do {
5
		do {
6
			ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
6
			ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
7
			if (binding != null) {
7
			if (binding != null) {
8
				finalName = (String) binding.logicalToPhysical.get( logicalName );
8
				logical = (String) binding.physicalToLogical.get( physicalName );
9
			}
9
			}
10
			String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
10
			String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
11
			TableDescription description = (TableDescription) tableNameBinding.get(key);
11
			description = (TableDescription) tableNameBinding.get(key);
12
			if (description != null) currentTable = description.denormalizedSupertable;
12
			if (description != null) currentTable = description.denormalizedSupertable;
13
		}
13
		}
14
		while (finalName == null && currentTable != null);
14
		while (logical == null && currentTable != null
15
		if (finalName
15
 && description != null);
16
 == null) {
16
		if (logical == null) {
17
			throw new MappingException( "Unable to find column with logical name "
17
			throw new MappingException( "Unable to find logical column name from physical name "
18
					+ logicalName + " in table " + table.getName() );
18
					+ physicalName + " in table " + table.getName() );
19
		}
19
		}
20
		return finalName;
20
		return logical;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.4
Clones locationClones are declared in the same class
Number of node comparisons23
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    ColumnNames binding = (ColumnNames)columnNameBindingPerTable.get(currentTable);
    4
    ColumnNames binding = (ColumnNames)columnNameBindingPerTable.get(currentTable);
    5
    if (binding != null)
    5
    if (binding != null)
    6
    finalName = (String)binding.logicalToPhysical.get(logicalName);
    6
    finalName = (String)binding.logicalToPhysical.get(logicalName);
    6
    logical = (String)binding.physicalToLogical.get(physicalName);
    Differences
    Expression1Expression2Difference
    finalNamelogicalVARIABLE_NAME_MISMATCH
    logicalNamephysicalNameVARIABLE_NAME_MISMATCH
    logicalToPhysicalphysicalToLogicalVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression binding.logicalToPhysical cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression binding.physicalToLogical cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    logical = (String)binding.physicalToLogical.get(physicalName);
    7
    String key = buildTableNameKey(currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName());
    7
    String key = buildTableNameKey(currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName());
                                                                                                                          
    8
    description = (TableDescription)tableNameBinding.get(key);
    Preondition Violations
    Unmatched statement description=(TableDescription)tableNameBinding.get(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    description = (TableDescription)tableNameBinding.get(key);
    8
    TableDescription description = (TableDescription)tableNameBinding.get(key);
    8
    TableDescription description = (TableDescription)tableNameBinding.get(key);
    Preondition Violations
    Unmatched statement TableDescription description=(TableDescription)tableNameBinding.get(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                            
    9
    if (description != null)
    9
    if (description != null)
    10
    currentTable = description.denormalizedSupertable;
    10
    currentTable = description.denormalizedSupertable;
    Precondition Violations (5)
    Row Violation
    1Expression binding.logicalToPhysical cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression binding.physicalToLogical cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement description=(TableDescription)tableNameBinding.get(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement TableDescription description=(TableDescription)tableNameBinding.get(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables key, finalName, currentTable , while Clone fragment #2 returns variables key, logical, currentTable