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 testSaveParentWithOrphanDeleteChild()
|
Method name: void testSaveOrphanDeleteChildWithParentFailureExpected()
|
|||
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 | DeleteOrphanChild child = new DeleteOrphanChild();↵ | 4 | DeleteOrphanChild child = new DeleteOrphanChild();↵ | |
5 | child.setParent( parent );↵ | 5 | child.setParent( parent );↵ | |
6 | parent.setDeleteOrphanChildren( Collections.singleton( child ) );↵ | 6 | parent.setDeleteOrphanChildren( Collections.singleton( child ) );↵ | |
7 | session.save( parent );↵ | 7 | session.save( child );↵ | |
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( 0, parent.getChildren().size() );↵ | 13 | assertEquals( 0, parent.getChildren().size() );↵ | |
14 | assertEquals( 1, 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 | 101 |
Number of mapped statements | 17 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
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 | DeleteOrphanChild child = new DeleteOrphanChild(); | |||||||||||||||||
5 | child.setParent(parent); | 5 | child.setParent(parent); | |||||||||||||||||
6 | parent.setDeleteOrphanChildren(Collections.singleton(child)); | 6 | parent.setDeleteOrphanChildren(Collections.singleton(child)); | |||||||||||||||||
7 | session.save(parent); |
| 7 | session.save(child); | ||||||||||||||||
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(0, parent.getChildren().size()); | 13 | assertEquals(0, parent.getChildren().size()); | |||||||||||||||||
14 | assertEquals(1, 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 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Type org.hibernate.test.cascade.Parent of variable parent does not match with type org.hibernate.test.cascade.DeleteOrphanChild of variable child |