File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/set/PersistentSetTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/set/PersistentSetTest.java | |||
Method name: void testCollectiondirtyChecking()
|
Method name: void testCollectionMerging()
|
|||
Number of AST nodes: 27 | Number of AST nodes: 27 | |||
1 | Session session = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | session.beginTransaction();↵ | 2 | session.beginTransaction();↵ | |
3 | Parent parent = new Parent( "p1" );↵ | 3 | Parent parent = new Parent( "p1" );↵ | |
4 | Child child = new Child( "c1" );↵ | 4 | Child child = new Child( "c1" );↵ | |
5 | parent.getChildren().add( child );↵ | 5 | parent.getChildren().add( child );↵ | |
6 | child.setParent( parent );↵ | 6 | child.setParent( parent );↵ | |
7 | session.save( parent );↵ | 7 | session.save( parent );↵ | |
8 | session.getTransaction().commit();↵ | 8 | session.getTransaction().commit();↵ | |
9 | session.close();↵ | 9 | session.close();↵ | |
10 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics( Parent.class.getName() + ".children" );↵ | 10 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics( Parent.class.getName() + ".children" );↵ | |
11 | long recreateCount = stats.getRecreateCount();↵ | 11 | long recreateCount = stats.getRecreateCount();↵ | |
12 | long updateCount = stats.getUpdateCount();↵ | 12 | long updateCount = stats.getUpdateCount();↵ | |
13 | session = openSession();↵ | 13 | session = openSession();↵ | |
14 | session.beginTransaction();↵ | 14 | session.beginTransaction();↵ | |
15 | parent = ( Parent ) session.get( Parent.class, "p1" );↵ | 15 | parent = ( Parent ) session.↵ | |
16 | assertEquals( 1, parent.getChildren().size() );↵ | 16 | merge( parent );↵ | |
17 | session.getTransaction().commit();↵ | 17 | session.getTransaction().commit();↵ | |
18 | session.close();↵ | 18 | session.close();↵ | |
19 | assertEquals( 1, parent.getChildren().size() );↵ | 19 | assertEquals( 1, parent.getChildren().size() );↵ | |
20 | assertEquals( recreateCount, stats.getRecreateCount() );↵ | 20 | assertEquals( recreateCount, stats.getRecreateCount() );↵ | |
21 | assertEquals( updateCount, stats.getUpdateCount() );↵ | 21 | assertEquals( updateCount, stats.getUpdateCount() );↵ | |
22 | session = openSession();↵ | 22 | session = openSession();↵ | |
23 | session.beginTransaction();↵ | 23 | session.beginTransaction();↵ | |
24 | ↵ | 24 | parent = ( Parent ) session.get( Parent.class, "p1" );↵ | |
25 | assertEquals( 1, parent.getChildren().size() );↵ | 25 | assertEquals( 1, parent.getChildren().size() );↵ | |
26 | session.delete( parent );↵ | 26 | session.delete( parent );↵ | |
27 | session.getTransaction().commit();↵ | 27 | session.getTransaction().commit();↵ | |
28 | session.close(); | 28 |
| |
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 | 165 |
Number of mapped statements | 26 |
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 | session.beginTransaction(); | 2 | session.beginTransaction(); | |||||||||||||||||||||||||
3 | Parent parent = new Parent("p1"); | 3 | Parent parent = new Parent("p1"); | |||||||||||||||||||||||||
4 | Child child = new Child("c1"); | 4 | Child child = new Child("c1"); | |||||||||||||||||||||||||
5 | parent.getChildren().add(child); | 5 | parent.getChildren().add(child); | |||||||||||||||||||||||||
6 | child.setParent(parent); | 6 | child.setParent(parent); | |||||||||||||||||||||||||
7 | session.save(parent); | 7 | session.save(parent); | |||||||||||||||||||||||||
8 | session.getTransaction().commit(); | 8 | session.getTransaction().commit(); | |||||||||||||||||||||||||
9 | session.close(); | 9 | session.close(); | |||||||||||||||||||||||||
10 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics(Parent.class.getName() + ".children"); | 10 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics(Parent.class.getName() + ".children"); | |||||||||||||||||||||||||
11 | long recreateCount = stats.getRecreateCount(); | 11 | long recreateCount = stats.getRecreateCount(); | |||||||||||||||||||||||||
12 | long updateCount = stats.getUpdateCount(); | 12 | long updateCount = stats.getUpdateCount(); | |||||||||||||||||||||||||
13 | session = openSession(); | 13 | session = openSession(); | |||||||||||||||||||||||||
14 | session.beginTransaction(); | 14 | session.beginTransaction(); | |||||||||||||||||||||||||
15 | parent = (Parent)session.get(Parent.class, "p1"); |
| 15 | parent = (Parent)session.merge(parent); | ||||||||||||||||||||||||
16 | assertEquals(1, parent.getChildren().size()); |
| 25 | session.delete(parent); | ||||||||||||||||||||||||
17 | session.getTransaction().commit(); | 16 | session.getTransaction().commit(); | |||||||||||||||||||||||||
18 | session.close(); | 17 | session.close(); | |||||||||||||||||||||||||
19 | assertEquals(1, parent.getChildren().size()); | 18 | assertEquals(1, parent.getChildren().size()); | |||||||||||||||||||||||||
20 | assertEquals(recreateCount, stats.getRecreateCount()); | 19 | assertEquals(recreateCount, stats.getRecreateCount()); | |||||||||||||||||||||||||
21 | assertEquals(updateCount, stats.getUpdateCount()); | 20 | assertEquals(updateCount, stats.getUpdateCount()); | |||||||||||||||||||||||||
22 | session = openSession(); | 21 | session = openSession(); | |||||||||||||||||||||||||
23 | session.beginTransaction(); | 22 | session.beginTransaction(); | |||||||||||||||||||||||||
|
| 23 | parent = (Parent)session.get(Parent.class, "p1"); | |||||||||||||||||||||||||
24 | assertEquals(1, parent.getChildren().size()); | 24 | assertEquals(1, parent.getChildren().size()); | |||||||||||||||||||||||||
25 | session.delete(parent); | | ||||||||||||||||||||||||||
26 | session.getTransaction().commit(); | 26 | session.getTransaction().commit(); | |||||||||||||||||||||||||
27 | session.close(); | 27 | session.close(); |
Row | Violation |
---|---|
1 | Expression session.get(Parent.class,"p1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression session.merge(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression session.get(Parent.class,"p1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression session.merge(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression assertEquals(1,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression session.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression assertEquals(1,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized |
8 | Expression session.delete(parent) is a void method call, and thus it cannot be parameterized |
9 | Expression assertEquals(1,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression session.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertEquals(1,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized |
12 | Expression session.delete(parent) is a void method call, and thus it cannot be parameterized |
13 | Unmatched statement parent=(Parent)session.get(Parent.class,"p1"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Clone fragment #1 returns variables parent, session , while Clone fragment #2 returns variables session |