try { ResultSet rs = qps.executeQuery(); if ( !rs.next() ) { String err = "could not read a hi value - you need to populate the table: " + tableName; log.error(err); throw new IdentifierGenerationException(err); } result = rs.getInt(1); rs.close(); } catch (SQLException sqle) { log.error("could not read a hi value", sqle); throw sqle; } finally { qps.close(); }
try { ResultSet selectRS = selectPS.executeQuery(); if ( !selectRS.next() ) { String err = "could not read a hi value - you need to populate the table: " + tableName; log.error( err ); throw new IdentifierGenerationException( err ); } result = selectRS.getLong( 1 ); selectRS.close(); } catch ( SQLException sqle ) { log.error( "could not read a hi value", sqle ); throw sqle; } finally { selectPS.close(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/id/TableGenerator.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/id/enhanced/TableStructure.java
Method name: Serializable doWorkInCurrentTransaction(Connection, String) Method name: Serializable doWorkInCurrentTransaction(Connection, String)
Number of AST nodes: 8 Number of AST nodes: 8
1
try {
1
try {
2
				ResultSet rs = qps.executeQuery();
2
				ResultSet selectRS = selectPS.executeQuery();
3
				if ( !rs.next() ) {
3
				if ( !selectRS.next() ) {
4
					String err = "could not read a hi value - you need to populate the table: " + tableName;
4
					String err = "could not read a hi value - you need to populate the table: " + tableName;
5
					log.error(err);
5
					log.error( err );
6
					throw new IdentifierGenerationException(err);
6
					throw new IdentifierGenerationException( err );
7
				}
7
				}
8
				result = rs.getInt(1);
8
				result = selectRS.getLong( 1 );
9
				rs.close();
9
				selectRS.close();
10
			}
10
			}
11
			catch (SQLException sqle) {
11
			catch ( SQLException sqle ) {
12
				log.error("could not read a hi value", sqle);
12
				log.error( "could not read a hi value", sqle );
13
				throw sqle;
13
				throw sqle;
14
			}
14
			}
15
			finally {
15
			finally {
16
				qps.close();
16
				selectPS.close();
17
			}
17
			}
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 in different classes having the same super class
Number of node comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    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.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    try
    6
    try
    5
    try
    Differences
    Expression1Expression2Difference
    qpsselectPSVARIABLE_NAME_MISMATCH
    5
    try
    7
    ResultSet rs = qps.executeQuery();
    7
    ResultSet rs = qps.executeQuery();
    6
    ResultSet selectRS = selectPS.executeQuery();
    Differences
    Expression1Expression2Difference
    rsselectRSVARIABLE_NAME_MISMATCH
    qpsselectPSVARIABLE_NAME_MISMATCH
    6
    ResultSet selectRS = selectPS.executeQuery();
    8
    if (!rs.next())
    8
    if (!rs.next())
    7
    if (!selectRS.next())
    Differences
    Expression1Expression2Difference
    rsselectRSVARIABLE_NAME_MISMATCH
    7
    if (!selectRS.next())
    9
    String err = "could not read a hi value - you need to populate the table: " + tableName;
    8
    String err = "could not read a hi value - you need to populate the table: " + tableName;
    10
    log.error(err);
    9
    log.error(err);
    11
    throw new IdentifierGenerationException(err);
    10
    throw new IdentifierGenerationException(err);
                                                                  
    11
    result = selectRS.getLong(1);
    Preondition Violations
    Unmatched statement result=selectRS.getLong(1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result=selectRS.getLong(1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    11
    result = selectRS.getLong(1);
    12
    result = rs.getInt(1);
    12
    result = rs.getInt(1);
    Preondition Violations
    Unmatched statement result=rs.getInt(1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result=rs.getInt(1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                    
    13
    rs.close();
    13
    rs.close();
    12
    selectRS.close();
    Differences
    Expression1Expression2Difference
    rsselectRSVARIABLE_NAME_MISMATCH
    12
    selectRS.close();
    Precondition Violations (4)
    Row Violation
    1Unmatched statement result=selectRS.getLong(1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement result=selectRS.getLong(1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    3Unmatched statement result=rs.getInt(1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement result=rs.getInt(1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted