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 testManyToOnePropertyRefGeneratedIds()
|
Method name: void testOneToOnePropertyRefGeneratedIds()
|
|||
Number of AST nodes: 10 | Number of AST nodes: 11 | |||
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 | ↵ | |
5 | Other other = new Other(↵ | 5 | Child c2 = new Child( "c2" );↵ | |
6 | ChildInfo info = new ChildInfo( "blah blah blah" );↵ | |||
6 | );↵ | 7 | c2.setInfo( info );↵ | |
7 | other.setOwner( p );↵ | 8 | info.setOwner( c2 );↵ | |
8 | s.persist( other );↵ | 9 | s.persist( c2 );↵ | |
9 | try {↵ | 10 | try {↵ | |
10 | s.getTransaction().commit();↵ | 11 | s.getTransaction().commit();↵ | |
11 | fail( "expecting TransientObjectException on flush" );↵ | 12 | fail( "expecting TransientObjectException on flush" );↵ | |
12 | }↵ | 13 | }↵ | |
13 | catch( TransientObjectException e ) {↵ | 14 | catch( TransientObjectException e ) {↵ | |
14 | // expected result↵ | 15 | // expected result↵ | |
15 | log.trace( "handled expected exception", e );↵ | 16 | log.trace( "handled expected exception : " + e );↵ | |
16 | s.getTransaction().rollback();↵ | 17 | s.getTransaction().rollback();↵ | |
17 | }↵ | 18 | }↵ | |
18 | finally {↵ | 19 | finally {↵ | |
19 | s.close();↵ | 20 | s.close();↵ | |
20 | }↵ | 21 | }↵ | |
21 | }↵ | 22 | }↵ | |
22 | finally {↵ | 23 | finally {↵ | |
23 | cleanupData();↵ | 24 | cleanupData();↵ | |
24 | } | 25 |
| |
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.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 65 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 2.0 |
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 | Child c2 = new Child("c2"); | |||||||||||||||||||||||
4 | Parent p = new Parent("parent"); | | |||||||||||||||||||||||
| 5 | ChildInfo info = new ChildInfo("blah blah blah"); | |||||||||||||||||||||||
5 | Other other = new Other(); | | |||||||||||||||||||||||
| 6 | c2.setInfo(info); | |||||||||||||||||||||||
6 | other.setOwner(p); |
| 7 | info.setOwner(c2); | |||||||||||||||||||||
7 | s.persist(other); |
| 8 | s.persist(c2); | |||||||||||||||||||||
8 | try |
| 9 | try | |||||||||||||||||||||
9 | s.getTransaction().commit(); | 10 | s.getTransaction().commit(); | ||||||||||||||||||||||
10 | fail("expecting TransientObjectException on flush"); | 11 | 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.Child of variable c2 |
2 | Type org.hibernate.test.jpa.cascade.Other of variable other does not match with type org.hibernate.test.jpa.cascade.ChildInfo of variable info |
3 | Type org.hibernate.test.jpa.cascade.Other of variable other does not match with type org.hibernate.test.jpa.cascade.Child of variable c2 |
4 | Expression log.trace("handled expected exception",e) is a void method call, and thus it cannot be parameterized |
5 | Expression log.trace("handled expected exception : " + e) is a void method call, and thus it cannot be parameterized |