File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/reattachment/CollectionReattachmentTest.java | |||
Method name: void testPutAgainstUninitializedMap()
|
Method name: void testUpdateOwnerAfterClear()
|
|||
Number of AST nodes: 19 | Number of AST nodes: 19 | |||
1 | Session session = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | session.beginTransaction();↵ | 2 | s.beginTransaction();↵ | |
3 | Parent parent = new Parent( "p1" );↵ | 3 | Parent p = new Parent( "p" );↵ | |
4 | session↵ | 4 | p.getChildren().add( new Child( "c" ) );↵ | |
5 | .save( parent );↵ | 5 | s.save( p );↵ | |
6 | session.getTransaction().commit();↵ | 6 | s.getTransaction().commit();↵ | |
7 | session.close();↵ | 7 | s.close();↵ | |
8 | // Now, reload the parent and test adding children↵ | 8 | ↵ | |
9 | session = openSession();↵ | 9 | s = openSession();↵ | |
10 | session.beginTransaction();↵ | 10 | s.beginTransaction();↵ | |
11 | parent = ( Parent ) session.get( Parent.class, parent.getName() );↵ | 11 | p = ( Parent ) s.get( Parent.class, ↵ | |
12 | parent.addChild( "c1" );↵ | |||
13 | parent.addChild( "c2"↵ | 12 | "p" );↵ | |
13 | // clear...↵ | |||
14 | s.clear();↵ | |||
15 | // now try to reattach...↵ | |||
14 | );↵ | 16 | s.update( p );↵ | |
15 | session.getTransaction().commit();↵ | 17 | s.getTransaction().commit();↵ | |
16 | session.close();↵ | 18 | s.close();↵ | |
17 | assertEquals( 2, parent.getChildren().size() );↵ | 19 | ↵ | |
18 | session = openSession();↵ | 20 | s = openSession();↵ | |
19 | session.beginTransaction();↵ | 21 | s.beginTransaction();↵ | |
20 | session.delete( parent );↵ | 22 | s.delete( p );↵ | |
21 | session.getTransaction().commit();↵ | 23 | s.getTransaction().commit();↵ | |
22 | session.close(); | 24 | s.close(); | |
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 in different classes having the same super class |
Number of node comparisons | 361 |
Number of mapped statements | 14 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session session = openSession(); |
| 1 | Session s = openSession(); | |||||||||||||||||
2 | session.beginTransaction(); |
| 2 | s.beginTransaction(); | |||||||||||||||||
|
| 3 | Parent p = new Parent("p"); | ||||||||||||||||||
3 | Parent parent = new Parent("p1"); |
| | ||||||||||||||||||
| 4 | p.getChildren().add(new Child("c")); | |||||||||||||||||||
4 | session.save(parent); |
| 5 | s.save(p); | |||||||||||||||||
5 | session.getTransaction().commit(); |
| 6 | s.getTransaction().commit(); | |||||||||||||||||
6 | session.close(); |
| 7 | s.close(); | |||||||||||||||||
7 | session = openSession(); |
| 8 | s = openSession(); | |||||||||||||||||
8 | session.beginTransaction(); |
| 9 | s.beginTransaction(); | |||||||||||||||||
9 | parent = (Parent)session.get(Parent.class, parent.getName()); |
| | ||||||||||||||||||
|
| 10 | p = (Parent)s.get(Parent.class, "p"); | ||||||||||||||||||
10 | parent.addChild("c1"); | | |||||||||||||||||||
|
| 11 | s.clear(); | ||||||||||||||||||
11 | parent.addChild("c2"); | | |||||||||||||||||||
|
| 12 | s.update(p); | ||||||||||||||||||
12 | session.getTransaction().commit(); |
| 13 | s.getTransaction().commit(); | |||||||||||||||||
13 | session.close(); |
| 14 | s.close(); | |||||||||||||||||
14 | assertEquals(2, parent.getChildren().size()); | | |||||||||||||||||||
15 | session = openSession(); |
| 15 | s = openSession(); | |||||||||||||||||
16 | session.beginTransaction(); |
| 16 | s.beginTransaction(); | |||||||||||||||||
17 | session.delete(parent); |
| 17 | s.delete(p); | |||||||||||||||||
18 | session.getTransaction().commit(); |
| 18 | s.getTransaction().commit(); | |||||||||||||||||
19 | session.close(); |
| 19 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement Parent p=new Parent("p"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement Parent parent=new Parent("p1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.reattachment.Parent of variable p |
4 | Unmatched statement parent=(Parent)session.get(Parent.class,parent.getName()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement p=(Parent)s.get(Parent.class,"p"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement s.update(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.reattachment.Parent of variable p |