try { offset+= expectation.prepare( st ); //TODO: copy/paste from insertRows() int loc = writeKey( st, id, offset, session ); if ( hasIdentifier ) { loc = writeIdentifier( st, collection.getIdentifier(entry, i), loc, session ); } if ( hasIndex /*&& !indexIsFormula*/ ) { loc = writeIndex( st, collection.getIndex(entry, i, this), loc, session ); } loc = writeElement(st, collection.getElement(entry), loc, session ); if ( useBatch ) { session.getBatcher().addToBatch( expectation ); } else { expectation.verifyOutcome( st.executeUpdate(), st, -1 ); } collection.afterRowInsert( this, entry, i ); count++; } catch ( SQLException sqle ) { if ( useBatch ) { session.getBatcher().abortBatch( sqle ); } throw sqle; } finally { if ( !useBatch ) { session.getBatcher().closeStatement( st ); } }
try { offset += expectation.prepare( st ); //TODO: copy/paste from recreate() offset = writeKey( st, id, offset, session ); if ( hasIdentifier ) { offset = writeIdentifier( st, collection.getIdentifier(entry, i), offset, session ); } if ( hasIndex /*&& !indexIsFormula*/ ) { offset = writeIndex( st, collection.getIndex(entry, i, this), offset, session ); } writeElement(st, collection.getElement(entry), offset, session ); if ( useBatch ) { session.getBatcher().addToBatch( expectation ); } else { expectation.verifyOutcome( st.executeUpdate(), st, -1 ); } collection.afterRowInsert( this, entry, i ); count++; } catch ( SQLException sqle ) { if ( useBatch ) { session.getBatcher().abortBatch( sqle ); } throw sqle; } finally { if ( !useBatch ) { session.getBatcher().closeStatement( st ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
Method name: void recreate(PersistentCollection, Serializable, SessionImplementor) Method name: void insertRows(PersistentCollection, Serializable, SessionImplementor)
Number of AST nodes: 13 Number of AST nodes: 13
1
try {
1
try {
2
								offset+= expectation.prepare( st );
2
							offset += expectation.prepare( st );
3
								//TODO: copy/paste from insertRows()
3
							//TODO: copy/paste from recreate()
4
								int loc = writeKey( st, id, offset, session );
4
							offset = writeKey( st, id, offset, session );
5
								if ( hasIdentifier ) {
5
							if ( hasIdentifier ) {
6
									loc = writeIdentifier( st, collection.getIdentifier(entry, i), loc, session );
6
								offset = writeIdentifier( st, collection.getIdentifier(entry, i), offset, session );
7
								}
7
							}
8
								if ( hasIndex /*&& !indexIsFormula*/ ) {
8
							if ( hasIndex /*&& !indexIsFormula*/ ) {
9
									loc = writeIndex( st, collection.getIndex(entry, i, this), loc, session );
9
								offset = writeIndex( st, collection.getIndex(entry, i, this), offset, session );
10
								}
10
							}
11
								loc = writeElement(st, collection.getElement(entry), loc, session );
11
							writeElement(st, collection.getElement(entry), offset, session );
12
								if ( useBatch ) {
12
							if ( useBatch ) {
13
									session.getBatcher().addToBatch( expectation );
13
								session.getBatcher().addToBatch( expectation );
14
								}
14
							}
15
								else {
15
							else {
16
									expectation.verifyOutcome( st.executeUpdate(), st, -1 );
16
								expectation.verifyOutcome( st.executeUpdate(), st, -1 );
17
								}
17
							}
18
								collection.afterRowInsert( this, entry, i );
18
							collection.afterRowInsert( this, entry, i );
19
								count++;
19
							count++;
20
							}
20
						}
21
							catch ( SQLException sqle ) {
21
						catch ( SQLException sqle ) {
22
								if ( useBatch ) {
22
							if ( useBatch ) {
23
									session.getBatcher().abortBatch( sqle );
23
								session.getBatcher().abortBatch( sqle );
24
								}
24
							}
25
								throw sqle;
25
							throw sqle;
26
							}
26
						}
27
							finally {
27
						finally {
28
								if ( !useBatch ) {
28
							if ( !useBatch ) {
29
									session.getBatcher().closeStatement( st );
29
								session.getBatcher().closeStatement( st );
30
								}
30
							}
31
							}
31
						}
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.9
Clones locationClones are declared in the same class
Number of node comparisons74
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)13.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    26
    try
    26
    try
    27
    offset += expectation.prepare(st);
    27
    offset += expectation.prepare(st);
                                                                                        
    28
    offset = writeKey(st, id, offset, session);
    Preondition Violations
    Unmatched statement offset=writeKey(st,id,offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement offset=writeKey(st,id,offset,session); 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
    28
    offset = writeKey(st, id, offset, session);
    28
    int loc = writeKey(st, id, offset, session);
    28
    int loc = writeKey(st, id, offset, session);
    Preondition Violations
    Unmatched statement int loc=writeKey(st,id,offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement int loc=writeKey(st,id,offset,session); 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
                                                                                          
    29
    if (hasIdentifier)
    29
    if (hasIdentifier)
    30
    loc = writeIdentifier(st, collection.getIdentifier(entry, i), loc, session);
    30
    loc = writeIdentifier(st, collection.getIdentifier(entry, i), loc, session);
    30
    offset = writeIdentifier(st, collection.getIdentifier(entry, i), offset, session);
    Differences
    Expression1Expression2Difference
    locoffsetVARIABLE_NAME_MISMATCH
    locoffsetVARIABLE_NAME_MISMATCH
    30
    offset = writeIdentifier(st, collection.getIdentifier(entry, i), offset, session);
    31
    if (hasIndex)
    31
    if (hasIndex)
    32
    loc = writeIndex(st, collection.getIndex(entry, i, this), loc, session);
    32
    loc = writeIndex(st, collection.getIndex(entry, i, this), loc, session);
    32
    offset = writeIndex(st, collection.getIndex(entry, i, this), offset, session);
    Differences
    Expression1Expression2Difference
    locoffsetVARIABLE_NAME_MISMATCH
    locoffsetVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression loc cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression offset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression loc cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression offset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32
    offset = writeIndex(st, collection.getIndex(entry, i, this), offset, session);
                                                                                                                                      
    33
    writeElement(st, collection.getElement(entry), offset, session);
    Preondition Violations
    Unmatched statement writeElement(st,collection.getElement(entry),offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement writeElement(st,collection.getElement(entry),offset,session); 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
    33
    writeElement(st, collection.getElement(entry), offset, session);
    33
    loc = writeElement(st, collection.getElement(entry), loc, session);
    33
    loc = writeElement(st, collection.getElement(entry), loc, session);
    Preondition Violations
    Unmatched statement loc=writeElement(st,collection.getElement(entry),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement loc=writeElement(st,collection.getElement(entry),loc,session); 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
                                                                                                                                        
    34
    if (useBatch)
    34
    if (useBatch)
    35
    session.getBatcher().addToBatch(expectation);
    35
    session.getBatcher().addToBatch(expectation);
    else
    else
    36
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    36
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    37
    collection.afterRowInsert(this, entry, i);
    37
    collection.afterRowInsert(this, entry, i);
    38
    count++;
    38
    count++;
    Precondition Violations (13)
    Row Violation
    1Unmatched statement offset=writeKey(st,id,offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement offset=writeKey(st,id,offset,session); 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 int loc=writeKey(st,id,offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement int loc=writeKey(st,id,offset,session); 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
    5Expression loc cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression offset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression loc cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression offset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Unmatched statement writeElement(st,collection.getElement(entry),offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement writeElement(st,collection.getElement(entry),offset,session); 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
    11Unmatched statement loc=writeElement(st,collection.getElement(entry),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement loc=writeElement(st,collection.getElement(entry),loc,session); 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
    13Clone fragment #1 returns variables offset, loc, count , while Clone fragment #2 returns variables offset, count