File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/optlock/OptimisticLockTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/optlock/OptimisticLockTest.java | |||
Method name: void testUpdateOptimisticLockFailure(String)
|
Method name: void testDeleteOptimisticLockFailure(String)
|
|||
Number of AST nodes: 4 | Number of AST nodes: 4 | |||
1 | try {↵ | 1 | try {↵ | |
2 | doc.setSummary( "A machiavelian achievement of epic proportions" );↵ | 2 | mainSession.delete( doc );↵ | |
3 | mainSession.flush();↵ | 3 | mainSession.flush();↵ | |
4 | fail( "expecting opt lock failure" );↵ | 4 | fail( "expecting opt lock failure" );↵ | |
5 | }↵ | 5 | }↵ | |
6 | catch ( StaleObjectStateException expected ) {↵ | 6 | catch ( StaleObjectStateException e ) {↵ | |
7 | // expected result...↵ | 7 | // expected↵ | |
8 | }↵ | 8 | }↵ | |
9 | catch( StaleStateException expected ) {↵ | 9 | catch( StaleStateException expected ) {↵ | |
10 | // expected result (if using versioned batching)...↵ | 10 | // expected result (if using versioned batching)...↵ | |
11 | }↵ | 11 | }↵ | |
12 | catch( JDBCException e ) {↵ | 12 | catch( JDBCException e ) {↵ | |
13 | // SQLServer will report this condition via a SQLException↵ | 13 | // SQLServer will report this condition via a SQLException↵ | |
14 | // when using its SNAPSHOT transaction isolation...↵ | 14 | // when using its SNAPSHOT transaction isolation...↵ | |
15 | if ( ! ( getDialect() instanceof SQLServerDialect && e.getErrorCode() == 3960 ) ) {↵ | 15 | if ( ! ( getDialect() instanceof SQLServerDialect && e.getErrorCode() == 3960 ) ) {↵ | |
16 | throw e;↵ | 16 | throw e;↵ | |
17 | }↵ | 17 | }↵ | |
18 | else {↵ | 18 | else {↵ | |
19 | // it seems to "lose track" of the transaction as well...↵ | 19 | // it seems to "lose track" of the transaction as well...↵ | |
20 | mainSession.getTransaction().rollback();↵ | 20 | mainSession.getTransaction().rollback();↵ | |
21 | mainSession.beginTransaction();↵ | 21 | mainSession.beginTransaction();↵ | |
22 | }↵ | 22 | }↵ | |
23 | } | 23 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 16 |
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 1.2 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
24 | try |
| 30 | try | ||||||||||||||||||||
|
| 31 | mainSession.delete(doc); | |||||||||||||||||||||
25 | doc.setSummary("A machiavelian achievement of epic proportions"); |
| 33 | fail("expecting opt lock failure"); | ||||||||||||||||||||
26 | mainSession.flush(); | 32 | mainSession.flush(); | |||||||||||||||||||||
27 | fail("expecting opt lock failure"); | |
Row | Violation |
---|---|
1 | Unmatched statement mainSession.delete(doc); 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 |
2 | Expression doc.setSummary("A machiavelian achievement of epic proportions") is a void method call, and thus it cannot be parameterized |
3 | Expression fail("expecting opt lock failure") is a void method call, and thus it cannot be parameterized |
4 | Expression doc.setSummary("A machiavelian achievement of epic proportions") is a void method call, and thus it cannot be parameterized |
5 | Expression fail("expecting opt lock failure") is a void method call, and thus it cannot be parameterized |