if ( !isInverse && isRowInsertEnabled() ) { if ( log.isDebugEnabled() ) { log.debug( "Inserting collection: " + MessageHelper.collectionInfoString( this, id, getFactory() ) ); } try { //create all the new entries Iterator entries = collection.entries(this); if ( entries.hasNext() ) { collection.preInsert( this ); int i = 0; int count = 0; while ( entries.hasNext() ) { final Object entry = entries.next(); if ( collection.entryExists( entry, i ) ) { int offset = 1; PreparedStatement st = null; Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() ); boolean callable = isInsertCallable(); boolean useBatch = expectation.canBeBatched(); String sql = getSQLInsertRowString(); if ( useBatch ) { 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 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 ); } } } i++; } if ( log.isDebugEnabled() ) { log.debug( "done inserting collection: " + count + " rows inserted" ); } } else { if ( log.isDebugEnabled() ) { log.debug( "collection was empty" ); } } } catch ( SQLException sqle ) { throw JDBCExceptionHelper.convert( sqlExceptionConverter, sqle, "could not insert collection: " + MessageHelper.collectionInfoString( this, id, getFactory() ), getSQLInsertRowString() ); } }
if ( !isInverse && isRowInsertEnabled() ) { if ( log.isDebugEnabled() ) { log.debug( "Inserting rows of collection: " + MessageHelper.collectionInfoString( this, id, getFactory() ) ); } 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() ); } }
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: 43 Number of AST nodes: 41
1
if ( !isInverse && isRowInsertEnabled() ) {
1
if ( !isInverse && isRowInsertEnabled() ) {
2
			if ( log.isDebugEnabled() ) {
2
			if ( log.isDebugEnabled() ) {
3
				log.debug( 
3
				log.debug( 
4
						"Inserting collection: " + 
4
						"Inserting rows of collection: " + 
5
						MessageHelper.collectionInfoString( this, id, getFactory() ) 
5
						MessageHelper.collectionInfoString( this, id, getFactory() ) 
6
					);
6
					);
7
			}
7
			}
8
			try {
8
			try {
9
				//create all the new entries
9
				//insert all the new entries
10
				Iterator entries = collection.entries(this);
10
				
11
				if ( entries.hasNext() ) {
12
					collection.preInsert( this );
13
					int i = 0;
14
					int count = 0;
15
					while ( entries.hasNext() ) {
16
						final Object entry = entries.next();
17
						if (
11
collection.preInsert( this );
18
 collection.entryExists( entry, i ) ) {
12
				Iterator entries = collection.entr
19
							int offset = 1;
20
							PreparedStatement st = null;
21
			
13
ies( this );
22
				Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() );
14
				Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() );
23
							boolean callable = isInsertCallable();
15
				boolean callable = isInsertCallable();
24
							boolean useBatch = expectation.canBeBatched();
16
				boolean useBatch = expectation.canBeBatched();
25
							String sql = getSQLInsertRowString();
17
				String sql = getSQLInsertRowString();
26
							if ( useBatch
18
				int i = 0;
19
				int count = 0;
20
				while ( entries.hasNext() ) {
21
					int offset = 1;
22
					Object entry = entries.next();
23
					PreparedStatement st = null;
24
					if ( collection.needsInserting( entry, i, elementType ) ) {
25
						if ( useBatch ) {
27
 ) {
26
							if ( st == null ) {
28
								if ( callable ) {
27
								if ( callable ) {
29
									st = session.getBatcher().prepareBatchCallableStatement( sql );
28
									st = session.getBatcher().prepareBatchCallableStatement( sql );
30
								}
29
								}
31
								else {
30
								else {
32
									st = session.getBatcher().prepareBatchStatement( sql );
31
									st = session.getBatcher().prepareBatchStatement( sql );
33
								}
32
								}
34
							}
33
							}
35
						
34
						}
36
	else {
35
						else {
37
								if ( callable ) {
36
							if ( callable ) {
38
									st = session.getBatcher().prepareCallableStatement( sql );
37
								st = session.getBatcher().prepareCallableStatement( sql );
39
								}
38
							}
40
								else {
39
							else {
41
									st = session.getBatcher().prepareStatement( sql );
40
								st = session.getBatcher().prepareStatement( sql );
42
								}
41
							}
43
							}
42
						
43
}
44
							try {
44
						try {
45
								offset+= expectation.prepare( st );
45
							offset += expectation.prepare( st );
46
								//TODO: copy/paste from insertRows()
46
							//TODO: copy/paste from recreate()
47
								int loc = writeKey( st, id, offset, session );
47
							offset = writeKey( st, id, offset, session );
48
								if ( hasIdentifier ) {
48
							if ( hasIdentifier ) {
49
									loc = writeIdentifier( st, collection.getIdentifier(entry, i), loc, session );
49
								offset = writeIdentifier( st, collection.getIdentifier(entry, i), offset, session );
50
								}
50
							}
51
								if ( hasIndex /*&& !indexIsFormula*/ ) {
51
							if ( hasIndex /*&& !indexIsFormula*/ ) {
52
									loc = writeIndex( st, collection.getIndex(entry, i, this), loc, session );
52
								offset = writeIndex( st, collection.getIndex(entry, i, this), offset, session );
53
								}
53
							}
54
								loc = writeElement(st, collection.getElement(entry), loc, session );
54
							writeElement(st, collection.getElement(entry), offset, session );
55
								if ( useBatch ) {
55
							if ( useBatch ) {
56
									session.getBatcher().addToBatch( expectation );
56
								session.getBatcher().addToBatch( expectation );
57
								}
57
							}
58
								else {
58
							else {
59
									expectation.verifyOutcome( st.executeUpdate(), st, -1 );
59
								expectation.verifyOutcome( st.executeUpdate(), st, -1 );
60
								}
60
							}
61
								collection.afterRowInsert( this, entry, i );
61
							collection.afterRowInsert( this, entry, i );
62
								count++;
62
							count++;
63
							}
63
						}
64
							catch ( SQLException sqle ) {
64
						catch ( SQLException sqle ) {
65
								if ( useBatch ) {
65
							if ( useBatch ) {
66
									session.getBatcher().abortBatch( sqle );
66
								session.getBatcher().abortBatch( sqle );
67
								}
67
							}
68
								throw sqle;
68
							throw sqle;
69
							}
69
						}
70
							finally {
70
						finally {
71
								if ( !useBatch ) {
71
							if ( !useBatch ) {
72
									session.getBatcher().closeStatement( st );
72
								session.getBatcher().closeStatement( st );
73
								}
73
							}
74
							}
74
						
75
}
75
						}
76
					}
76
						i++;
77
					i++;
77
					}
78
				}
78
					if ( log.isDebugEnabled() ) {
79
				if ( log.isDebugEnabled() ) {
79
						log.debug( "done inserting collection: " + count + " rows inserted" );
80
					log.debug( "done inserting rows: " + count + " inserted" );
80
					}
81
				
81
				}
82
				else {
83
					if ( log.isDebugEnabled() ) {
84
						log.debug( "collection was empty" );
85
					}
86
				}
82
}
87
			}
83
			}
88
			catch ( SQLException sqle ) {
84
			catch ( SQLException sqle ) {
89
				throw JDBCExceptionHelper.convert(
85
				throw JDBCExceptionHelper.convert(
90
				        sqlExceptionConverter,
86
				        sqlExceptionConverter,
91
				        sqle,
87
				        sqle,
92
				        "could not insert collection: " + 
88
				        "could not insert collection rows: " + 
93
				        MessageHelper.collectionInfoString( this, id, getFactory() ),
89
				        MessageHelper.collectionInfoString( this, id, getFactory() ),
94
				        getSQLInsertRowString()
90
				        getSQLInsertRowString()
95
					);
91
					);
96
			}
92
			}
97
		}
93
		}
Summary
Number of common nesting structure subtrees4
Number of refactorable cases2
Number of non-refactorable cases2
Time elapsed for finding largest common nesting structure subtrees (ms)3.5
Clones locationClones are declared in the same class
Number of node comparisons170
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.9
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    20
    if (callable)
    20
    if (callable)
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    else
    else
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    Precondition Violations (0)
    Row Violation
  2. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    23
    if (callable)
    20
    if (callable)
    24
    st = session.getBatcher().prepareCallableStatement(sql);
    24
    st = session.getBatcher().prepareCallableStatement(sql);
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    Differences
    Expression1Expression2Difference
    prepareCallableStatementprepareBatchCallableStatementMETHOD_INVOCATION_NAME_MISMATCH
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    else
    else
    25
    st = session.getBatcher().prepareStatement(sql);
    25
    st = session.getBatcher().prepareStatement(sql);
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    Differences
    Expression1Expression2Difference
    prepareStatementprepareBatchStatementMETHOD_INVOCATION_NAME_MISMATCH
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    Precondition Violations (0)
    Row Violation
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements19
    Number of unmapped statements in the first code fragment16
    Number of unmapped statements in the second code fragment18
    Time elapsed for statement mapping (ms)28.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    7
    collection.preInsert(this);
    5
    collection.preInsert(this);
    8
    int i = 0;
    11
    int i = 0;
    9
    int count = 0;
    12
    int count = 0;
    10
    while (entries.hasNext())
    13
    while (entries.hasNext())
    11
    final Object entry = entries.next();
    11
    final Object entry = entries.next();
    Preondition Violations
    Unmatched statement final Object entry=entries.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
                                      
    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
    14
    int offset = 1;
                                                                    
    15
    Object entry = entries.next();
    Preondition Violations
    Unmatched statement Object entry=entries.next(); 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();
                                                                
    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
    16
    PreparedStatement st = null;
    12
    if (collection.entryExists(entry, i))
    12
    if (collection.entryExists(entry, i))
    17
    if (collection.needsInserting(entry, i, elementType))
    Differences
    Expression1Expression2Difference
    entryExistsneedsInsertingMETHOD_INVOCATION_NAME_MISMATCH
    collection.entryExists(entry,i)collection.needsInserting(entry,i,elementType)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression collection.entryExists(entry,i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression collection.entryExists(entry,i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17
    if (collection.needsInserting(entry, i, elementType))
    13
    int offset = 1;
    13
    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
                                      
    14
    PreparedStatement st = null;
    14
    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
                                                                
    15
    Expectation expectation = Expectations.appropriateExpectation(getInsertCheckStyle());
    15
    Expectation expectation = Expectations.appropriateExpectation(getInsertCheckStyle());
    Preondition Violations
    Unmatched statement Expectation expectation=Expectations.appropriateExpectation(getInsertCheckStyle()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                  
    16
    boolean callable = isInsertCallable();
    16
    boolean callable = isInsertCallable();
    Preondition Violations
    Unmatched statement boolean callable=isInsertCallable(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    17
    boolean useBatch = expectation.canBeBatched();
    17
    boolean useBatch = expectation.canBeBatched();
    Preondition Violations
    Unmatched statement boolean useBatch=expectation.canBeBatched(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                    
                                    
    18
    if (useBatch)
                                        
    19
    if (st == null)
                                    
    20
    if (callable)
                                                                                                                                  
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
            
    else
                                                                                                                  
    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
    22
    st = session.getBatcher().prepareBatchStatement(sql);
                                    
    23
    if (callable)
                                                                                                                        
    24
    st = session.getBatcher().prepareCallableStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24
    st = session.getBatcher().prepareCallableStatement(sql);
            
    else
                                                                                                        
    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
    25
    st = session.getBatcher().prepareStatement(sql);
    18
    String sql = getSQLInsertRowString();
    18
    String sql = getSQLInsertRowString();
    Preondition Violations
    Unmatched statement String sql=getSQLInsertRowString(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
    19
    if (useBatch)
                                    
    20
    if (callable)
                                    
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                  
    else
            
    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
                                                                                                                  
    23
    if (callable)
                                    
    24
    st = session.getBatcher().prepareCallableStatement(sql);
    24
    st = session.getBatcher().prepareCallableStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                        
    else
            
    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
                                                                                                        
    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++;
    39
    i++;
    39
    i++;
    40
    if (log.isDebugEnabled())
    40
    if (log.isDebugEnabled())
    41
    log.debug("done inserting collection: " + count + " rows inserted");
    41
    log.debug("done inserting collection: " + count + " rows inserted");
    41
    log.debug("done inserting rows: " + count + " inserted");
    Differences
    Expression1Expression2Difference
    " rows inserted"" inserted"LITERAL_VALUE_MISMATCH
    "done inserting collection: ""done inserting rows: "LITERAL_VALUE_MISMATCH
    41
    log.debug("done inserting rows: " + count + " inserted");
    Precondition Violations (35)
    Row Violation
    1Unmatched statement final Object entry=entries.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements 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 Object entry=entries.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement PreparedStatement st=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression collection.entryExists(entry,i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression collection.entryExists(entry,i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Unmatched statement int offset=1; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement PreparedStatement st=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement Expectation expectation=Expectations.appropriateExpectation(getInsertCheckStyle()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement boolean callable=isInsertCallable(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement boolean useBatch=expectation.canBeBatched(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched 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
    16Unmatched statement st=session.getBatcher().prepareCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched 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
    18Unmatched statement String sql=getSQLInsertRowString(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched 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
    21Unmatched statement st=session.getBatcher().prepareCallableStatement(sql); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched 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
    23Unmatched 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
    24Unmatched 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
    25Unmatched 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
    26Unmatched 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
    27Expression loc cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression offset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression loc cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression offset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Unmatched 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
    32Unmatched 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
    33Unmatched 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
    34Unmatched 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
    35Clone fragment #1 returns variables offset, loc , while Clone fragment #2 returns variables offset
  2. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)2.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    42
    if (log.isDebugEnabled())
    42
    if (log.isDebugEnabled())
    20
    if (callable)
    Differences
    Expression1Expression2Difference
    log.isDebugEnabled()callableTYPE_COMPATIBLE_REPLACEMENT
    20
    if (callable)
                                                                                                                                  
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved, because it updates a variable modified in other unmapped statements
    21
    st = session.getBatcher().prepareBatchCallableStatement(sql);
            
    else
                                                                                                                  
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    Preondition Violations
    Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved, because it updates a variable modified in other unmapped statements
    22
    st = session.getBatcher().prepareBatchStatement(sql);
    43
    log.debug("collection was empty");
                                                                                
    Precondition Violations (2)
    Row Violation
    1Unmatched statement st=session.getBatcher().prepareBatchCallableStatement(sql); cannot be moved, because it updates a variable modified in other unmapped statements
    2Unmatched statement st=session.getBatcher().prepareBatchStatement(sql); cannot be moved, because it updates a variable modified in other unmapped statements