File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/jpa/cascade/CascadeTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/jpa/cascade/CascadeTest.java | |||
Method name: void testManyToOneGeneratedIdsOnSave()
|
Method name: void testManyToOneGeneratedIds()
|
|||
Number of AST nodes: 10 | Number of AST nodes: 10 | |||
1 | try {↵ | 1 | try {↵ | |
2 | Session s = openSession();↵ | 2 | Session s = openSession();↵ | |
3 | s.beginTransaction();↵ | 3 | s.beginTransaction();↵ | |
4 | Parent p = new Parent( "parent" );↵ | 4 | Parent p = new Parent( "parent" );↵ | |
5 | Child c = new Child( "child" );↵ | 5 | Child c = new Child( "child" );↵ | |
6 | c.setParent( p );↵ | 6 | c.setParent( p );↵ | |
7 | s.save( c );↵ | 7 | s.persist( c );↵ | |
8 | try {↵ | 8 | try {↵ | |
9 | s.getTransaction().commit();↵ | 9 | s.getTransaction().commit();↵ | |
10 | fail( "expecting TransientObjectException on flush" );↵ | 10 | fail( "expecting TransientObjectException on flush" );↵ | |
11 | }↵ | 11 | }↵ | |
12 | catch( TransientObjectException e ) {↵ | 12 | catch( TransientObjectException e ) {↵ | |
13 | // expected result↵ | 13 | // expected result↵ | |
14 | log.trace( "handled expected exception", e );↵ | 14 | log.trace( "handled expected exception", e );↵ | |
15 | s.getTransaction().rollback();↵ | 15 | s.getTransaction().rollback();↵ | |
16 | }↵ | 16 | }↵ | |
17 | finally {↵ | 17 | finally {↵ | |
18 | s.close();↵ | 18 | s.close();↵ | |
19 | }↵ | 19 | }↵ | |
20 | }↵ | 20 | }↵ | |
21 | finally {↵ | 21 | finally {↵ | |
22 | cleanupData();↵ | 22 | cleanupData();↵ | |
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.4 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 58 |
Number of mapped statements | 9 |
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.7 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
1 | try | 1 | try | ||||
2 | Session s = openSession(); | 2 | Session s = openSession(); | ||||
3 | s.beginTransaction(); | 3 | s.beginTransaction(); | ||||
4 | Parent p = new Parent("parent"); | 4 | Parent p = new Parent("parent"); | ||||
5 | Child c = new Child("child"); | 5 | Child c = new Child("child"); | ||||
6 | c.setParent(p); | 6 | c.setParent(p); | ||||
|
| 7 | s.persist(c); | ||||
7 | s.save(c); |
| | ||||
8 | try | 8 | try | ||||
9 | s.getTransaction().commit(); | 9 | s.getTransaction().commit(); | ||||
10 | fail("expecting TransientObjectException on flush"); | 10 | fail("expecting TransientObjectException on flush"); |
Row | Violation |
---|---|
1 | Unmatched statement s.persist(c); 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 | Unmatched statement s.save(c); 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 | Clone fragment #1 returns variables s, c , while Clone fragment #2 returns variables s, c |