ResultSet rs = null; try { rs = meta.getColumns(catalog, schema, name, "%"); while ( rs.next() ) addColumn(rs); } finally { if (rs != null) rs.close(); }
ResultSet rs = null; try { rs = meta.getImportedKeys(catalog, schema, name); while ( rs.next() ) addForeignKey(rs); } finally { if (rs != null) rs.close(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/tool/hbm2ddl/TableMetadata.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/tool/hbm2ddl/TableMetadata.java
Method name: void initColumns(DatabaseMetaData) Method name: void initForeignKeys(DatabaseMetaData)
Number of AST nodes: 5 Number of AST nodes: 5
1
ResultSet rs = null;
1
ResultSet rs = null;
2
		
3
		try {
2
		try {
4
			rs = meta.getColumns(catalog, schema, name, "%");
3
			rs = meta.getImportedKeys(catalog, schema, name);
5
			while ( rs.next() ) addColumn(rs);
4
			while ( rs.next() ) addForeignKey(rs);
6
		}
5
		}
7
		finally  {
6
		finally {
8
			if (rs != null) rs.close();
7
			if (rs != null) rs.close();
9
		}
8
		}
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.2
Clones locationClones are declared in the same class
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    ResultSet rs = null;
    1
    ResultSet rs = null;
    2
    try
    2
    try
    3
    rs = meta.getColumns(catalog, schema, name, "%");
    3
    rs = meta.getColumns(catalog, schema, name, "%");
    3
    rs = meta.getImportedKeys(catalog, schema, name);
    Differences
    Expression1Expression2Difference
    getColumnsgetImportedKeysMETHOD_INVOCATION_NAME_MISMATCH
    meta.getColumns(catalog,schema,name,"%")meta.getImportedKeys(catalog,schema,name)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression meta.getColumns(catalog,schema,name,"%") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression meta.getImportedKeys(catalog,schema,name) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression meta.getColumns(catalog,schema,name,"%") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression meta.getImportedKeys(catalog,schema,name) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3
    rs = meta.getImportedKeys(catalog, schema, name);
    4
    while (rs.next())
    4
    while (rs.next())
    5
    addColumn(rs);
    5
    addColumn(rs);
    5
    addForeignKey(rs);
    Differences
    Expression1Expression2Difference
    addColumnaddForeignKeyMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression addColumn(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression addForeignKey(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method addForeignKey
    Expression addColumn(rs) is a void method call, and thus it cannot be parameterized
    Expression addForeignKey(rs) is a void method call, and thus it cannot be parameterized
    5
    addForeignKey(rs);
    Precondition Violations (8)
    Row Violation
    1Expression meta.getColumns(catalog,schema,name,"%") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    2Expression meta.getImportedKeys(catalog,schema,name) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3Expression meta.getColumns(catalog,schema,name,"%") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    4Expression meta.getImportedKeys(catalog,schema,name) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    5Expression addColumn(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression addForeignKey(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression addColumn(rs) is a void method call, and thus it cannot be parameterized
    8Expression addForeignKey(rs) is a void method call, and thus it cannot be parameterized