File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/cascade/BidirectionalOneToManyCascadeTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/cascade/BidirectionalOneToManyCascadeTest.java | |||
Method name: void testSaveParentWithChild()
|
Method name: void testSaveParentWithOrphanDeleteChild()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 17 | |||
1 | Session session = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | Transaction txn = session.beginTransaction();↵ | 2 | Transaction txn = session.beginTransaction();↵ | |
3 | Parent parent = new Parent();↵ | 3 | Parent parent = new Parent();↵ | |
4 | Child child = new Child();↵ | 4 | DeleteOrphanChild child = new DeleteOrphanChild();↵ | |
5 | child.setParent( parent );↵ | 5 | child.setParent( parent );↵ | |
6 | parent.setChildren( Collections.singleton( child ) );↵ | 6 | parent.setDeleteOrphanChildren( Collections.singleton( child ) );↵ | |
7 | session.save( parent );↵ | 7 | session.save( parent );↵ | |
8 | txn.commit();↵ | 8 | txn.commit();↵ | |
9 | session.close();↵ | 9 | session.close();↵ | |
10 | session = openSession();↵ | 10 | session = openSession();↵ | |
11 | txn = session.beginTransaction();↵ | 11 | txn = session.beginTransaction();↵ | |
12 | parent = ( Parent ) session.get( Parent.class, parent.getId() );↵ | 12 | parent = ( Parent ) session.get( Parent.class, parent.getId() );↵ | |
13 | assertEquals( 1, parent.getChildren().size() );↵ | 13 | assertEquals( 0, parent.getChildren().size() );↵ | |
14 | assertEquals( 0, parent.getDeleteOrphanChildren().size() );↵ | 14 | assertEquals( 1, parent.getDeleteOrphanChildren().size() );↵ | |
15 | session.delete( parent );↵ | 15 | session.delete( parent );↵ | |
16 | txn.commit();↵ | 16 | txn.commit();↵ | |
17 | session.close(); | 17 |
| |
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.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 117 |
Number of mapped statements | 16 |
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) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session session = openSession(); | 1 | Session session = openSession(); | |||||||||||||||||||||||
2 | Transaction txn = session.beginTransaction(); | 2 | Transaction txn = session.beginTransaction(); | |||||||||||||||||||||||
3 | Parent parent = new Parent(); | 3 | Parent parent = new Parent(); | |||||||||||||||||||||||
| 4 | DeleteOrphanChild child = new DeleteOrphanChild(); | ||||||||||||||||||||||||
4 | Child child = new Child(); | | ||||||||||||||||||||||||
5 | child.setParent(parent); |
| 5 | child.setParent(parent); | ||||||||||||||||||||||
6 | parent.setChildren(Collections.singleton(child)); |
| 6 | parent.setDeleteOrphanChildren(Collections.singleton(child)); | ||||||||||||||||||||||
7 | session.save(parent); | 7 | session.save(parent); | |||||||||||||||||||||||
8 | txn.commit(); | 8 | txn.commit(); | |||||||||||||||||||||||
9 | session.close(); | 9 | session.close(); | |||||||||||||||||||||||
10 | session = openSession(); | 10 | session = openSession(); | |||||||||||||||||||||||
11 | txn = session.beginTransaction(); | 11 | txn = session.beginTransaction(); | |||||||||||||||||||||||
12 | parent = (Parent)session.get(Parent.class, parent.getId()); | 12 | parent = (Parent)session.get(Parent.class, parent.getId()); | |||||||||||||||||||||||
13 | assertEquals(1, parent.getChildren().size()); |
| 13 | assertEquals(0, parent.getChildren().size()); | ||||||||||||||||||||||
14 | assertEquals(0, parent.getDeleteOrphanChildren().size()); |
| 14 | assertEquals(1, parent.getDeleteOrphanChildren().size()); | ||||||||||||||||||||||
15 | session.delete(parent); | 15 | session.delete(parent); | |||||||||||||||||||||||
16 | txn.commit(); | 16 | txn.commit(); | |||||||||||||||||||||||
17 | session.close(); | 17 | session.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.cascade.Child of variable child does not match with type org.hibernate.test.cascade.DeleteOrphanChild of variable child |
2 | Expression parent.setChildren(Collections.singleton(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression parent.setDeleteOrphanChildren(Collections.singleton(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression parent.setChildren(Collections.singleton(child)) is a void method call, and thus it cannot be parameterized |
5 | Expression parent.setDeleteOrphanChildren(Collections.singleton(child)) is a void method call, and thus it cannot be parameterized |
6 | Type java.util.Set<org.hibernate.test.cascade.Child> of variable Collections.singleton(child) does not match with type java.util.Set<org.hibernate.test.cascade.DeleteOrphanChild> of variable Collections.singleton(child) |
7 | Type org.hibernate.test.cascade.Child of variable child does not match with type org.hibernate.test.cascade.DeleteOrphanChild of variable child |