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 testOneToOneGeneratedIds()
|
Method name: void testManyToOneAssignedIds()
|
|||
Number of AST nodes: 11 | 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 | ParentAssigned p = new Parent↵ | |
5 | ParentInfo info = new ParentInfo( "xyz" );↵ | |||
6 | p.setInfo( info );↵ | |||
7 | info.setOwner↵ | 5 | Assigned( new Long( 1 ), "parent" );↵ | |
6 | ChildAssigned c = new ChildAssigned( new Long( 2 ), "child" );↵ | |||
8 | ( p );↵ | 7 | c.setParent( p );↵ | |
9 | s.persist( p );↵ | 8 | s.persist( c );↵ | |
10 | try {↵ | 9 | try {↵ | |
11 | s.getTransaction().commit();↵ | 10 | s.getTransaction().commit();↵ | |
12 | fail( "expecting TransientObjectException on flush" );↵ | 11 | fail( "expecting TransientObjectException on flush" );↵ | |
13 | }↵ | 12 | }↵ | |
14 | catch( TransientObjectException e ) {↵ | 13 | catch( TransientObjectException e ) {↵ | |
15 | // expected result↵ | 14 | // expected result↵ | |
16 | log.trace( "handled expected exception", e );↵ | 15 | log.trace( "handled expected exception", e );↵ | |
17 | s.getTransaction().rollback();↵ | 16 | s.getTransaction().rollback();↵ | |
18 | }↵ | 17 | }↵ | |
19 | finally {↵ | 18 | finally {↵ | |
20 | s.close();↵ | 19 | s.close();↵ | |
21 | }↵ | 20 | }↵ | |
22 | }↵ | 21 | }↵ | |
23 | finally {↵ | 22 | finally {↵ | |
24 | cleanupData();↵ | 23 | cleanupData();↵ | |
25 | } | 24 |
| |
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 | 65 |
Number of mapped statements | 7 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 2.1 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | try | 1 | try | |||||||||||||||
2 | Session s = openSession(); | 2 | Session s = openSession(); | |||||||||||||||
3 | s.beginTransaction(); | 3 | s.beginTransaction(); | |||||||||||||||
| 4 | ParentAssigned p = new ParentAssigned(new Long(1), "parent"); | ||||||||||||||||
4 | Parent p = new Parent("parent"); | | ||||||||||||||||
| 5 | ChildAssigned c = new ChildAssigned(new Long(2), "child"); | ||||||||||||||||
5 | ParentInfo info = new ParentInfo("xyz"); | | ||||||||||||||||
| 6 | c.setParent(p); | ||||||||||||||||
6 | p.setInfo(info); | | ||||||||||||||||
7 | info.setOwner(p); | | ||||||||||||||||
8 | s.persist(p); |
| 7 | s.persist(c); | ||||||||||||||
9 | try | 8 | try | |||||||||||||||
10 | s.getTransaction().commit(); | 9 | s.getTransaction().commit(); | |||||||||||||||
11 | fail("expecting TransientObjectException on flush"); | 10 | fail("expecting TransientObjectException on flush"); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.jpa.cascade.Parent of variable p does not match with type org.hibernate.test.jpa.cascade.ChildAssigned of variable c |