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