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: 26 | Number of AST nodes: 23 | |||
1 | int offset = 1;↵ | |||
2 | Object entry = entries.next();↵ | |||
3 | PreparedStatement st = null;↵ | |||
4 | if ( collection.needsInserting( entry, i, elementType ) ) {↵ | 1 | if ( collection.needsUpdating( entry, i, elementType ) ) {↵ | |
5 | ↵ | 2 | int offset = 1;↵ | |
6 | if ( useBatch ) {↵ | 3 | if ( useBatch ) {↵ | |
7 | if ( st == null ) {↵ | 4 | if ( st == null ) {↵ | |
8 | if ( callable ) {↵ | 5 | if ( callable ) {↵ | |
9 | st = session.getBatcher().prepareBatchCallableStatement( sql );↵ | 6 | st = session.getBatcher().prepareBatchCallableStatement( sql );↵ | |
10 | }↵ | 7 | }↵ | |
11 | else {↵ | 8 | else {↵ | |
12 | st = session.getBatcher().prepareBatchStatement( sql );↵ | 9 | st = session.getBatcher().prepareBatchStatement( sql );↵ | |
13 | }↵ | 10 | }↵ | |
14 | }↵ | 11 | }↵ | |
15 | }↵ | 12 | }↵ | |
16 | else {↵ | 13 | else {↵ | |
17 | if ( callable ) {↵ | 14 | if ( callable ) {↵ | |
18 | st = session.getBatcher().prepareCallableStatement( sql );↵ | 15 | st = session.getBatcher().prepareCallableStatement( sql );↵ | |
19 | }↵ | 16 | }↵ | |
20 | else {↵ | 17 | else {↵ | |
21 | st = session.getBatcher().prepareStatement( sql );↵ | 18 | st = session.getBatcher().prepareStatement( sql );↵ | |
22 | }↵ | 19 | }↵ | |
23 | }↵ | 20 | }↵ | |
24 | try {↵ | 21 | try {↵ | |
25 | offset += expectation.prepare( st );↵ | 22 | offset+= expectation.prepare( st );↵ | |
26 | //TODO: copy/paste from recreate()↵ | 23 | ↵ | |
27 | offset = writeKey( st, id, offset, session );↵ | 24 | int loc = writeElement( st, collection.getElement( entry ), offset, session );↵ | |
28 | if ( hasIdentifier ) {↵ | 25 | if ( hasIdentifier ) {↵ | |
29 | offset = writeIdentifier( st, collection.getIdentifier(entry, i), offset, session );↵ | 26 | writeIdentifier( st, collection.getIdentifier( entry, i ), loc, session );↵ | |
30 | }↵ | 27 | }↵ | |
28 | else {↵ | |||
29 | loc = writeKey( st, id, loc, session );↵ | |||
31 | if ( hasIndex /*&& !indexIsFormula*/ ) {↵ | 30 | if ( hasIndex && !indexContainsFormula ) {↵ | |
32 | offset = writeIndex( st, collection.getIndex(entry, i, this), offset, session );↵ | 31 | writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session );↵ | |
33 | }↵ | 32 | }↵ | |
34 | ↵ | 33 | else {↵ | |
35 | writeElement(st, collection.getElement(entry), offset, session );↵ | 34 | writeElementToWhere( st, collection.getSnapshotElement( entry, i ), loc, session );↵ | |
36 | ↵ | 35 | }↵ | |
36 | }↵ | |||
37 | if ( useBatch ) {↵ | 37 | if ( useBatch ) {↵ | |
38 | session.getBatcher().addToBatch( expectation );↵ | 38 | session.getBatcher().addToBatch( expectation );↵ | |
39 | }↵ | 39 | }↵ | |
40 | else {↵ | 40 | else {↵ | |
41 | expectation.verifyOutcome( st.executeUpdate(), st, -1 );↵ | 41 | expectation.verifyOutcome( st.executeUpdate(), st, -1 );↵ | |
42 | }↵ | 42 | }↵ | |
43 | collection.afterRowInsert( this, entry, i );↵ | 43 | ↵ | |
44 | count++;↵ | |||
45 | }↵ | 44 | }↵ | |
46 | catch ( SQLException sqle ) {↵ | 45 | catch ( SQLException sqle ) {↵ | |
47 | if ( useBatch ) {↵ | 46 | if ( useBatch ) {↵ | |
48 | session.getBatcher().abortBatch( sqle );↵ | 47 | session.getBatcher().abortBatch( sqle );↵ | |
49 | }↵ | 48 | }↵ | |
50 | throw sqle;↵ | 49 | throw sqle;↵ | |
51 | }↵ | 50 | }↵ | |
52 | finally {↵ | 51 | finally {↵ | |
53 | if ( !useBatch ) {↵ | 52 | if ( !useBatch ) {↵ | |
54 | session.getBatcher().closeStatement( st );↵ | 53 | session.getBatcher().closeStatement( st );↵ | |
55 | }↵ | 54 | }↵ | |
56 | }↵ | 55 | }↵ | |
57 | }↵ | 56 | ↵ | |
58 | i++; | 57 | count++;↵ | |
58 |
| |||
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 2 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 2 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.9 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 85 |
Number of mapped statements | 7 |
Number of unmapped statements in the first code fragment | 18 |
Number of unmapped statements in the second code fragment | 16 |
Time elapsed for statement mapping (ms) | 29.3 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
14 | int offset = 1; | | |||||||||||||
15 | Object entry = entries.next(); |
| | ||||||||||||
16 | PreparedStatement st = null; |
| | ||||||||||||
17 | if (collection.needsInserting(entry, i, elementType)) |
| 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); | ||||||||||||
22 | st = session.getBatcher().prepareBatchStatement(sql); |
| | ||||||||||||
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); | ||||||||||||
25 | st = session.getBatcher().prepareStatement(sql); |
| | ||||||||||||
|
| 24 | try | ||||||||||||
|
| 25 | offset += expectation.prepare(st); | ||||||||||||
|
| 26 | int loc = writeElement(st, collection.getElement(entry), offset, session); | ||||||||||||
| 27 | if (hasIdentifier) | |||||||||||||
|
| 28 | writeIdentifier(st, collection.getIdentifier(entry, i), loc, session); | ||||||||||||
| else | ||||||||||||||
|
| 29 | loc = writeKey(st, id, loc, session); | ||||||||||||
| 30 | if (hasIndex && !indexContainsFormula) | |||||||||||||
|
| 31 | writeIndexToWhere(st, collection.getIndex(entry, i, this), loc, session); | ||||||||||||
| else | ||||||||||||||
|
| 32 | writeElementToWhere(st, collection.getSnapshotElement(entry, i), loc, session); | ||||||||||||
| 33 | if (useBatch) | |||||||||||||
|
| 34 | session.getBatcher().addToBatch(expectation); | ||||||||||||
| else | ||||||||||||||
|
| 35 | expectation.verifyOutcome(st.executeUpdate(), st, -1); | ||||||||||||
26 | try |
| | ||||||||||||
27 | offset += expectation.prepare(st); |
| | ||||||||||||
28 | offset = writeKey(st, id, offset, session); |
| | ||||||||||||
29 | if (hasIdentifier) | | |||||||||||||
30 | offset = writeIdentifier(st, collection.getIdentifier(entry, i), offset, session); |
| | ||||||||||||
31 | if (hasIndex) | | |||||||||||||
32 | offset = writeIndex(st, collection.getIndex(entry, i, this), offset, session); |
| | ||||||||||||
33 | writeElement(st, collection.getElement(entry), offset, session); |
| | ||||||||||||
34 | if (useBatch) | | |||||||||||||
35 | session.getBatcher().addToBatch(expectation); |
| | ||||||||||||
else | | ||||||||||||||
36 | expectation.verifyOutcome(st.executeUpdate(), st, -1); |
| | ||||||||||||
37 | collection.afterRowInsert(this, entry, i); |
| | ||||||||||||
38 | count++; | | |||||||||||||
| 36 | count++; |
Row | Violation |
---|---|
1 | 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 |
2 | 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 |
3 | Expression collection.needsInserting(entry,i,elementType) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | 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 |
5 | 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 |
6 | 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 |
7 | 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 |
8 | 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 |
9 | 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 |
10 | Unmatched statement st=session.getBatcher().prepareStatement(sql); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
11 | 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 |
12 | Unmatched statement try cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | 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 |
14 | 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 |
15 | 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 |
16 | 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 |
17 | 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 |
18 | 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 |
19 | 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 |
20 | 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 |
21 | 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 |
22 | 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 |
23 | Unmatched statement try cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | 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 |
25 | 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 |
26 | 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 |
27 | 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 | 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 |
29 | 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 |
30 | 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 |
31 | 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 |
32 | 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 |
33 | 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 |
34 | Unmatched statement collection.afterRowInsert(this,entry,i); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
35 | 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 |
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 3.1 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
27 | offset += expectation.prepare(st); | | ||||||||||||
28 | offset = writeKey(st, id, offset, session); |
| | |||||||||||
33 | writeElement(st, collection.getElement(entry), offset, session); |
| | |||||||||||
34 | if (useBatch) |
| 18 | if (callable) | ||||||||||
|
| 19 | st = session.getBatcher().prepareBatchCallableStatement(sql); | |||||||||||
35 | session.getBatcher().addToBatch(expectation); |
| | |||||||||||
else | | |||||||||||||
|
| 20 | st = session.getBatcher().prepareBatchStatement(sql); | |||||||||||
36 | expectation.verifyOutcome(st.executeUpdate(), st, -1); |
| |
Row | Violation |
---|---|
1 | 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 |
2 | 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 |
3 | 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 |
4 | 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 |
5 | Unmatched statement session.getBatcher().addToBatch(expectation); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | 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 |
7 | 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 |
8 | 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 |
9 | 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 |
10 | The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero |