try { //insert all the new entries collection.preInsert( this ); Iterator entries = collection.entries( this ); Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() ); boolean callable = isInsertCallable(); boolean useBatch = expectation.canBeBatched(); String sql = getSQLInsertRowString(); int i = 0; int count = 0; while ( entries.hasNext() ) { int offset = 1; Object entry = entries.next(); PreparedStatement st = null; if ( collection.needsInserting( entry, i, elementType ) ) { if ( useBatch ) { if ( st == null ) { if ( callable ) { st = session.getBatcher().prepareBatchCallableStatement( sql ); } else { st = session.getBatcher().prepareBatchStatement( sql ); } } } else { if ( callable ) { st = session.getBatcher().prepareCallableStatement( sql ); } else { st = session.getBatcher().prepareStatement( sql ); } } 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 ); } } } i++; } if ( log.isDebugEnabled() ) { log.debug( "done inserting rows: " + count + " inserted" ); } } catch ( SQLException sqle ) { throw JDBCExceptionHelper.convert( sqlExceptionConverter, sqle, "could not insert collection rows: " + MessageHelper.collectionInfoString( this, id, getFactory() ), getSQLInsertRowString() ); }
try { PreparedStatement st = null; Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() ); boolean callable = isUpdateCallable(); boolean useBatch = expectation.canBeBatched(); Iterator entries = collection.entries( this ); String sql = getSQLUpdateRowString(); int i = 0; int count = 0; while ( entries.hasNext() ) { Object entry = entries.next(); if ( collection.needsUpdating( entry, i, elementType ) ) { int offset = 1; if ( useBatch ) { if ( st == null ) { if ( callable ) { st = session.getBatcher().prepareBatchCallableStatement( sql ); } else { st = session.getBatcher().prepareBatchStatement( sql ); } } } else { if ( callable ) { st = session.getBatcher().prepareCallableStatement( sql ); } else { st = session.getBatcher().prepareStatement( sql ); } } try { offset+= expectation.prepare( st ); int loc = writeElement( st, collection.getElement( entry ), offset, session ); if ( hasIdentifier ) { writeIdentifier( st, collection.getIdentifier( entry, i ), loc, session ); } else { loc = writeKey( st, id, loc, session ); if ( hasIndex && !indexContainsFormula ) { writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session ); } else { writeElementToWhere( st, collection.getSnapshotElement( entry, i ), loc, session ); } } if ( useBatch ) { session.getBatcher().addToBatch( expectation ); } else { expectation.verifyOutcome( st.executeUpdate(), st, -1 ); } } catch ( SQLException sqle ) { if ( useBatch ) { session.getBatcher().abortBatch( sqle ); } throw sqle; } finally { if ( !useBatch ) { session.getBatcher().closeStatement( st ); } } count++; } i++; } return count; } catch ( SQLException sqle ) { throw JDBCExceptionHelper.convert( getSQLExceptionConverter(), sqle, "could not update collection rows: " + MessageHelper.collectionInfoString( this, id, getFactory() ), getSQLUpdateRowString() ); }
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/BasicCollectionPersister.java
Method name: void insertRows(PersistentCollection, Serializable, SessionImplementor) Method name: int doUpdateRows(Serializable, PersistentCollection, SessionImplementor)
Number of AST nodes: 38 Number of AST nodes: 36
1
try {
1
try {
2
				//insert all the new entries
2
			
3
				collection.preInsert( this );
4
				Iterator entries = collection.entries( this );
3
PreparedStatement st = null;
5
				Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() );
4
			Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() );
6
				boolean callable = isInsertCallable();
5
			boolean callable = isUpdateCallable();
7
				boolean useBatch = expectation.canBeBatched();
6
			boolean useBatch = expectation.canBeBatched();
8
			
7
			Iterator entries = collection.entries( this );
9
	String sql = getSQLInsertRowString();
8
			String sql = getSQLUpdateRowString();
10
				int i = 0;
9
			int i = 0;
11
				int count = 0;
10
			int count = 0;
12
				while ( entries.hasNext() ) {
11
			while ( entries.hasNext() ) {
13
					int offset = 1;
12
				
14
					Object entry = entries.next();
13
Object entry = entries.next();
15
					PreparedStatement st = null;
14
				
16
					if ( collection.needsInserting( entry, i, elementType ) ) {
15
if ( collection.needsUpdating( entry, i, elementType ) ) {
17
	
16
					int offset = 1;
18
					if ( useBatch ) {
17
					if ( useBatch ) {
19
							if ( st == null ) {
18
						if ( st == null ) {
20
								if ( callable ) {
19
							if ( callable ) {
21
									st = session.getBatcher().prepareBatchCallableStatement( sql );
20
								st = session.getBatcher().prepareBatchCallableStatement( sql );
22
								}
21
							}
23
								else {
22
							else {
24
									st = session.getBatcher().prepareBatchStatement( sql );
23
								st = session.getBatcher().prepareBatchStatement( sql );
25
								}
24
							}
26
							}
25
						}
27
						}
26
					}
28
						else {
27
					else {
29
							if ( callable ) {
28
						if ( callable ) {
30
								st = session.getBatcher().prepareCallableStatement( sql );
29
							st = session.getBatcher().prepareCallableStatement( sql );
31
							}
30
						}
32
							else {
31
						else {
33
								st = session.getBatcher().prepareStatement( sql );
32
							st = session.getBatcher().prepareStatement( sql );
34
							}
33
						}
35
						}
34
					}
36
						try {
35
					try {
37
							offset += expectation.prepare( st );
36
						offset+= expectation.prepare( st );
38
							//TODO: copy/paste from recreate()
37
						
39
							offset = writeKey( st, id, offset, session );
38
int loc = writeElement( st, collection.getElement( entry ), offset, session );
40
							if ( hasIdentifier ) {
39
						if ( hasIdentifier ) {
41
								offset = writeIdentifier( st, collection.getIdentifier(entry, i), offset, session );
40
							writeIdentifier( st, collection.getIdentifier( entry, i ), loc, session );
42
							}
41
						}
42
						else {
43
							loc = writeKey( st, id, loc, session );
43
							if ( hasIndex /*&& !indexIsFormula*/ ) {
44
							if ( hasIndex && !indexContainsFormula ) {
44
								offset = writeIndex( st, collection.getIndex(entry, i, this), offset, session );
45
								writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session );
45
							}
46
							}
46
							
47
							else {
47
writeElement(st, collection.getElement(entry), offset, session );
48
								writeElementToWhere( st, collection.getSnapshotElement( entry, i ), loc, session );
48
	
49
							}
50
						}
49
						if ( useBatch ) {
51
						if ( useBatch ) {
50
								session.getBatcher().addToBatch( expectation );
52
							session.getBatcher().addToBatch( expectation );
51
							}
53
						}
52
							else {
54
						else {
53
								expectation.verifyOutcome( st.executeUpdate(), st, -1 );
55
							expectation.verifyOutcome( st.executeUpdate(), st, -1 );
54
							}
56
						}
55
							collection.afterRowInsert( this, entry, i );
57
					
56
							count++;
57
						}
58
}
58
						catch ( SQLException sqle ) {
59
					catch ( SQLException sqle ) {
59
							if ( useBatch ) {
60
						if ( useBatch ) {
60
								session.getBatcher().abortBatch( sqle );
61
							session.getBatcher().abortBatch( sqle );
61
							}
62
						}
62
							throw sqle;
63
						throw sqle;
63
						}
64
					}
64
						finally {
65
					finally {
65
							if ( !useBatch ) {
66
						if ( !useBatch ) {
66
								session.getBatcher().closeStatement( st );
67
							session.getBatcher().closeStatement( st );
67
							}
68
						}
68
						}
69
					}
69
					}
70
					
70
					i++;
71
count++;
71
				}
72
				}
72
				if ( log.isDebugEnabled() ) {
73
				i
73
					log.debug( "done inserting rows: " + count + " inserted" );
74
				}
75
	
74
++;
75
			}
76
			return count;
76
		}
77
		}
77
			catch ( SQLException sqle ) {
78
		catch ( SQLException sqle ) {
78
				throw JDBCExceptionHelper.convert(
79
			throw JDBCExceptionHelper.convert(
79
				        sqlExceptionConverter,
80
					getSQLExceptionConverter(),
80
				        sqle,
81
					sqle,
81
				        "could not insert collection rows: " + 
82
					"could not update collection rows: " + 
82
				        MessageHelper.collectionInfoString( this, id, getFactory() ),
83
MessageHelper.collectionInfoString( this, id, getFactory() ),
83
				        getSQLInsertRowString()
84
					getSQLUpdateRowString()
84
					);
85
				);
85
			}
86
		}
Summary
Number of common nesting structure subtrees2
Number of refactorable cases0
Number of non-refactorable cases2
Time elapsed for finding largest common nesting structure subtrees (ms)4.7
Clones locationClones are in different classes having the same super class
Number of node comparisons189
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment20
    Number of unmapped statements in the second code fragment18
    Time elapsed for statement mapping (ms)123.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    4
    try
    4
    try
    3
    try
    Differences
    Expression1Expression2Difference
    sqlExceptionConvertergetSQLExceptionConverter()FIELD_ACCESS_REPLACED_WITH_GETTER
    "could not insert collection rows: ""could not update collection rows: "LITERAL_VALUE_MISMATCH
    getSQLInsertRowStringgetSQLUpdateRowStringMETHOD_INVOCATION_NAME_MISMATCH
    3
    try
                                                              
    4
    PreparedStatement st = null;
    5
    collection.preInsert(this);
    5
    collection.preInsert(this);
    Preondition Violations
    Unmatched statement collection.preInsert(this); 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
                                                                
    6
    Iterator entries = collection.entries(this);
    8
    Iterator entries = collection.entries(this);
    7
    Expectation expectation = Expectations.appropriateExpectation(getInsertCheckStyle());
    7
    Expectation expectation = Expectations.appropriateExpectation(getInsertCheckStyle());
    5
    Expectation expectation = Expectations.appropriateExpectation(getUpdateCheckStyle());
    Differences
    Expression1Expression2Difference
    getInsertCheckStylegetUpdateCheckStyleMETHOD_INVOCATION_NAME_MISMATCH
    5
    Expectation expectation = Expectations.appropriateExpectation(getUpdateCheckStyle());
    8
    boolean callable = isInsertCallable();
    8
    boolean callable = isInsertCallable();
    6
    boolean callable = isUpdateCallable();
    Differences
    Expression1Expression2Difference
    isInsertCallableisUpdateCallableMETHOD_INVOCATION_NAME_MISMATCH
    6
    boolean callable = isUpdateCallable();
    9
    boolean useBatch = expectation.canBeBatched();
    7
    boolean useBatch = expectation.canBeBatched();
    10
    String sql = getSQLInsertRowString();
    10
    String sql = getSQLInsertRowString();
    9
    String sql = getSQLUpdateRowString();
    Differences
    Expression1Expression2Difference
    getSQLInsertRowStringgetSQLUpdateRowStringMETHOD_INVOCATION_NAME_MISMATCH
    9
    String sql = getSQLUpdateRowString();
    11
    int i = 0;
    10
    int i = 0;
    12
    int count = 0;
    11
    int count = 0;
    13
    while (entries.hasNext())
    12
    while (entries.hasNext())
    14
    int offset = 1;
    14
    int offset = 1;
    Preondition Violations
    Unmatched statement int offset=1; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                      
    15
    Object entry = entries.next();
    13
    Object entry = entries.next();
    16
    PreparedStatement st = null;
    16
    PreparedStatement st = null;
    Preondition Violations
    Unmatched statement PreparedStatement st=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                
    17
    if (collection.needsInserting(entry, i, elementType))
    17
    if (collection.needsInserting(entry, i, elementType))
    14
    if (collection.needsUpdating(entry, i, elementType))
    Differences
    Expression1Expression2Difference
    needsInsertingneedsUpdatingMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression collection.needsUpdating(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    if (collection.needsUpdating(entry, i, elementType))
                                      
    15
    int offset = 1;
    18
    if (useBatch)
    16
    if (useBatch)
    19
    if (st == null)
    17
    if (st == null)
    20
    if (callable)
    18
    if (callable)
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    19
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    else
            
                                                                                                                  
    20
    st = session.getBatcher().prepareBatchStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); 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
    20
    st = session.getBatcher().prepareBatchStatement(sql);
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); 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
                                                                                                                  
    else
    else
    23
    if (callable)
    21
    if (callable)
    24
    st = session.getBatcher().prepareCallableStatement(sql);
    22
    st = session.getBatcher().prepareCallableStatement(sql);
    else
            
                                                                                                        
    23
    st = session.getBatcher().prepareStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement st=session.getBatcher().prepareStatement(sql); 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
    23
    st = session.getBatcher().prepareStatement(sql);
    25
    st = session.getBatcher().prepareStatement(sql);
    25
    st = session.getBatcher().prepareStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement st=session.getBatcher().prepareStatement(sql); 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
                                                                                                        
                  
    24
    try
    Preondition Violations
    Unmatched statement try cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24
    try
                                                                            
    25
    offset += expectation.prepare(st);
    Preondition Violations
    Unmatched statement offset+=expectation.prepare(st); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement offset+=expectation.prepare(st); 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
    25
    offset += expectation.prepare(st);
                                                                                                                                                      
    26
    int loc = writeElement(st, collection.getElement(entry), offset, session);
    Preondition Violations
    Unmatched statement int loc=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 int loc=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
    26
    int loc = writeElement(st, collection.getElement(entry), offset, session);
                                              
    27
    if (hasIdentifier)
                                                                                                                                                
    28
    writeIdentifier(st, collection.getIdentifier(entry, i), loc, session);
    Preondition Violations
    Unmatched statement writeIdentifier(st,collection.getIdentifier(entry,i),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28
    writeIdentifier(st, collection.getIdentifier(entry, i), loc, session);
            
    else
                                                                            
    29
    loc = writeKey(st, id, loc, session);
    Preondition Violations
    Unmatched statement loc=writeKey(st,id,loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29
    loc = writeKey(st, id, loc, session);
                                                                                      
    30
    if (hasIndex && !indexContainsFormula)
                                                                                                                                                    
    31
    writeIndexToWhere(st, collection.getIndex(entry, i, this), loc, session);
    Preondition Violations
    Unmatched statement writeIndexToWhere(st,collection.getIndex(entry,i,this),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    31
    writeIndexToWhere(st, collection.getIndex(entry, i, this), loc, session);
            
    else
                                                                                                                                                                  
    32
    writeElementToWhere(st, collection.getSnapshotElement(entry, i), loc, session);
    Preondition Violations
    Unmatched statement writeElementToWhere(st,collection.getSnapshotElement(entry,i),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    32
    writeElementToWhere(st, collection.getSnapshotElement(entry, i), loc, session);
                                    
    33
    if (useBatch)
    Preondition Violations
    Unmatched statement if(useBatch) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    33
    if (useBatch)
                                                                                                      
    34
    session.getBatcher().addToBatch(expectation);
    Preondition Violations
    Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    34
    session.getBatcher().addToBatch(expectation);
            
    else
                                                                                                                    
    35
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    Preondition Violations
    Unmatched statement expectation.verifyOutcome(st.executeUpdate(),st,-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    35
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    26
    try
    26
    try
    Preondition Violations
    Unmatched statement try cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                  
    27
    offset += expectation.prepare(st);
    27
    offset += expectation.prepare(st);
    Preondition Violations
    Unmatched statement offset+=expectation.prepare(st); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement offset+=expectation.prepare(st); 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
    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
                                                                                        
    29
    if (hasIdentifier)
                                              
    30
    offset = writeIdentifier(st, collection.getIdentifier(entry, i), offset, session);
    30
    offset = writeIdentifier(st, collection.getIdentifier(entry, i), offset, session);
    Preondition Violations
    Unmatched statement offset=writeIdentifier(st,collection.getIdentifier(entry,i),offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                    
    31
    if (hasIndex)
                                    
    32
    offset = writeIndex(st, collection.getIndex(entry, i, this), offset, session);
    32
    offset = writeIndex(st, collection.getIndex(entry, i, this), offset, session);
    Preondition Violations
    Unmatched statement offset=writeIndex(st,collection.getIndex(entry,i,this),offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                          
    33
    writeElement(st, collection.getElement(entry), 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
                                                                                                                                      
    34
    if (useBatch)
    34
    if (useBatch)
    Preondition Violations
    Unmatched statement if(useBatch) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    35
    session.getBatcher().addToBatch(expectation);
    35
    session.getBatcher().addToBatch(expectation);
    Preondition Violations
    Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                      
    else
            
    36
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    36
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    Preondition Violations
    Unmatched statement expectation.verifyOutcome(st.executeUpdate(),st,-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                    
    37
    collection.afterRowInsert(this, entry, i);
    37
    collection.afterRowInsert(this, entry, i);
    Preondition Violations
    Unmatched statement collection.afterRowInsert(this,entry,i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement collection.afterRowInsert(this,entry,i); 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
                                                                                            
    38
    count++;
    38
    count++;
    Preondition Violations
    Unmatched statement count++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                            
                            
    36
    count++;
    Preondition Violations
    Unmatched statement count++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    36
    count++;
    39
    i++;
    37
    i++;
                                      
    38
    return count;
    Preondition Violations
    Unmatched statement return count; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return count;
    38
    return count;
    40
    if (log.isDebugEnabled())
                                                            
    41
    log.debug("done inserting rows: " + count + " inserted");
    41
    log.debug("done inserting rows: " + count + " inserted");
    Preondition Violations
    Unmatched statement log.debug("done inserting rows: " + count + " inserted"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                              
    Precondition Violations (45)
    Row Violation
    1Unmatched statement collection.preInsert(this); 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
    2Unmatched statement int offset=1; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement PreparedStatement st=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression collection.needsUpdating(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); 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
    8Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); 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
    10Unmatched statement st=session.getBatcher().prepareStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement st=session.getBatcher().prepareStatement(sql); 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
    12Unmatched statement st=session.getBatcher().prepareStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement st=session.getBatcher().prepareStatement(sql); 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
    14Unmatched statement try cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement offset+=expectation.prepare(st); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement offset+=expectation.prepare(st); 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
    17Unmatched statement int loc=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
    18Unmatched statement int loc=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
    19Unmatched statement writeIdentifier(st,collection.getIdentifier(entry,i),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement loc=writeKey(st,id,loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Unmatched statement writeIndexToWhere(st,collection.getIndex(entry,i,this),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement writeElementToWhere(st,collection.getSnapshotElement(entry,i),loc,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement if(useBatch) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Unmatched statement expectation.verifyOutcome(st.executeUpdate(),st,-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    26Unmatched statement try cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Unmatched statement offset+=expectation.prepare(st); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28Unmatched statement offset+=expectation.prepare(st); 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
    29Unmatched 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
    30Unmatched 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
    31Unmatched statement offset=writeIdentifier(st,collection.getIdentifier(entry,i),offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    32Unmatched statement offset=writeIndex(st,collection.getIndex(entry,i,this),offset,session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    33Unmatched 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
    34Unmatched 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
    35Unmatched statement if(useBatch) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    36Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    37Unmatched statement expectation.verifyOutcome(st.executeUpdate(),st,-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    38Unmatched statement collection.afterRowInsert(this,entry,i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    39Unmatched statement collection.afterRowInsert(this,entry,i); 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
    40Unmatched statement count++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    41Unmatched statement count++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    42Unmatched statement return count; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    43Unmatched return count;
    44Unmatched statement log.debug("done inserting rows: " + count + " inserted"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    45Clone fragment #1 returns variables useBatch, st, expectation, i, entry, count , while Clone fragment #2 returns variables useBatch, st, expectation, entry, i, count
  2. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)4.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    27
    offset += expectation.prepare(st);
                                                                            
    28
    offset = writeKey(st, id, offset, session);
    28
    offset = writeKey(st, id, offset, session);
    Preondition Violations
    Unmatched statement offset=writeKey(st,id,offset,session); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
    33
    writeElement(st, collection.getElement(entry), 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 the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                      
    34
    if (useBatch)
    34
    if (useBatch)
    18
    if (callable)
    Differences
    Expression1Expression2Difference
    useBatchcallableVARIABLE_NAME_MISMATCH
    18
    if (callable)
                                                                                                                                  
    19
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); 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
    19
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    35
    session.getBatcher().addToBatch(expectation);
    35
    session.getBatcher().addToBatch(expectation);
    Preondition Violations
    Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement session.getBatcher().addToBatch(expectation); 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
                                                                                                      
    else
            
                                                                                                                  
    20
    st = session.getBatcher().prepareBatchStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); 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
    20
    st = session.getBatcher().prepareBatchStatement(sql);
    36
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    36
    expectation.verifyOutcome(st.executeUpdate(), st, -1);
    Preondition Violations
    Unmatched statement expectation.verifyOutcome(st.executeUpdate(),st,-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
                                                                                                                    
    Precondition Violations (10)
    Row Violation
    1Unmatched statement offset=writeKey(st,id,offset,session); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement writeElement(st,collection.getElement(entry),offset,session); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); 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
    5Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement session.getBatcher().addToBatch(expectation); 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
    7Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); 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
    9Unmatched statement expectation.verifyOutcome(st.executeUpdate(),st,-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
    10The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero