File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/iterate/IterateTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java | |||
Method name: void testIterate()
|
Method name: void testMergeManagedInitializedCollection()
|
|||
Number of AST nodes: 29 | Number of AST nodes: 29 | |||
1 | getSessions().getStatistics().clear();↵ | |||
2 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
3 | Transaction t = s.beginTransaction();↵ | 2 | Transaction tx = s.beginTransaction();↵ | |
4 | Item i1 = new Item("foo");↵ | 3 | ↵ | |
5 | Item i2 = new Item("bar");↵ | |||
6 | s.persist("Item", i1↵ | 4 | NumberedNode root = new NumberedNode( "root" );↵ | |
7 | );↵ | 5 | root.addChild( new NumberedNode( "child" ) );↵ | |
8 | s.persist("Item", i2);↵ | 6 | s.persist(root);↵ | |
9 | t.commit();↵ | 7 | tx.commit();↵ | |
10 | s.close();↵ | 8 | s.close();↵ | |
9 | clearCounts();↵ | |||
10 | NumberedNode newRoot = new NumberedNode( "root" );↵ | |||
11 | newRoot.setId( root.getId() );↵ | |||
11 | s = openSession();↵ | 12 | s = openSession();↵ | |
12 | t = s.beginTransaction();↵ | 13 | tx = s.beginTransaction();↵ | |
13 | Iterator iter = s.getNamedQuery("Item.nameDesc").iterate();↵ | 14 | ↵ | |
14 | i1 = (Item) iter.next();↵ | |||
15 | i2 = (Item) iter.next();↵ | |||
16 | assertFalse( ↵ | 15 | root = ( NumberedNode ) s.get( NumberedNode.class, root.getId() );↵ | |
16 | Set managedChildren = root.getChildren();↵ | |||
17 | Hibernate.isInitialized(i1) );↵ | 17 | Hibernate.initialize( managedChildren );↵ | |
18 | assertFalse( Hibernate.isInitialized(i2) );↵ | 18 | assertTrue( Hibernate.isInitialized(↵ | |
19 | i1.getName();↵ | |||
20 | i2.getName();↵ | |||
21 | assertFalse( Hibernate.isInitialized(i1↵ | 19 | managedChildren ) );↵ | |
20 | newRoot.setChildren( managedChildren );↵ | |||
21 | assertSame( root, s.merge( newRoot ) );↵ | |||
22 | ) );↵ | 22 | assertSame( managedChildren, root.getChildren() );↵ | |
23 | assertFalse( Hibernate.isInitialized(i2) );↵ | 23 | assertTrue( Hibernate.isInitialized(↵ | |
24 | assertEquals( i1.getName(), "foo" );↵ | |||
25 | assertEquals( i2.getName(), "bar" ↵ | 24 | managedChildren ) );↵ | |
25 | tx.commit();↵ | |||
26 | assertInsertCount(0);↵ | |||
27 | assertUpdateCount(0);↵ | |||
26 | );↵ | 28 | assertDeleteCount(0);↵ | |
27 | Hibernate.initialize(i1);↵ | 29 | tx = s.beginTransaction();↵ | |
28 | assertFalse( iter.hasNex↵ | 30 | assertEquals(↵ | |
31 | s.createCriteria(NumberedNode.class)↵ | |||
29 | t() );↵ | 32 | .setProjection( Projections.rowCount() )↵ | |
30 | s.delete(i1);↵ | |||
31 | s.delete(i2↵ | |||
33 | .uniqueResult(),↵ | |||
34 | new Integer(2)↵ | |||
32 | );↵ | 35 | );↵ | |
33 | t.commit();↵ | 36 | tx.commit();↵ | |
34 | s.close();↵ | 37 | s.close();↵ | |
35 | assertEquals( getSessions().getStatistics().getEntityFetchCount(), 2 ); | 38 | cleanup(); | |
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 | 604 |
Number of mapped statements | 20 |
Number of unmapped statements in the first code fragment | 9 |
Number of unmapped statements in the second code fragment | 9 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | getSessions().getStatistics().clear(); |
| 8 | clearCounts(); | ||||||||||||||||||||||
2 | Session s = openSession(); | 1 | Session s = openSession(); | |||||||||||||||||||||||
3 | Transaction t = s.beginTransaction(); |
| 2 | Transaction tx = s.beginTransaction(); | ||||||||||||||||||||||
| 3 | NumberedNode root = new NumberedNode("root"); | ||||||||||||||||||||||||
| 4 | root.addChild(new NumberedNode("child")); | ||||||||||||||||||||||||
4 | Item i1 = new Item("foo"); | | ||||||||||||||||||||||||
5 | Item i2 = new Item("bar"); | | ||||||||||||||||||||||||
6 | s.persist("Item", i1); |
| 22 | assertInsertCount(0); | ||||||||||||||||||||||
7 | s.persist("Item", i2); |
| 5 | s.persist(root); | ||||||||||||||||||||||
8 | t.commit(); |
| 6 | tx.commit(); | ||||||||||||||||||||||
9 | s.close(); | 7 | s.close(); | |||||||||||||||||||||||
| 9 | NumberedNode newRoot = new NumberedNode("root"); | ||||||||||||||||||||||||
| 10 | newRoot.setId(root.getId()); | ||||||||||||||||||||||||
10 | s = openSession(); | 11 | s = openSession(); | |||||||||||||||||||||||
11 | t = s.beginTransaction(); |
| 12 | tx = s.beginTransaction(); | ||||||||||||||||||||||
12 | Iterator iter = s.getNamedQuery("Item.nameDesc").iterate(); |
| | |||||||||||||||||||||||
|
| 13 | root = (NumberedNode)s.get(NumberedNode.class, root.getId()); | |||||||||||||||||||||||
13 | i1 = (Item)iter.next(); |
| | |||||||||||||||||||||||
| 14 | Set managedChildren = root.getChildren(); | ||||||||||||||||||||||||
14 | i2 = (Item)iter.next(); |
| | |||||||||||||||||||||||
| 17 | newRoot.setChildren(managedChildren); | ||||||||||||||||||||||||
15 | assertFalse(Hibernate.isInitialized(i1)); |
| 19 | assertSame(managedChildren, root.getChildren()); | ||||||||||||||||||||||
16 | assertFalse(Hibernate.isInitialized(i2)); |
| 18 | assertSame(root, s.merge(newRoot)); | ||||||||||||||||||||||
17 | i1.getName(); | | ||||||||||||||||||||||||
18 | i2.getName(); | | ||||||||||||||||||||||||
19 | assertFalse(Hibernate.isInitialized(i1)); |
| 29 | cleanup(); | ||||||||||||||||||||||
20 | assertFalse(Hibernate.isInitialized(i2)); |
| 26 | assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(), new Integer(2)); | ||||||||||||||||||||||
21 | assertEquals(i1.getName(), "foo"); |
| 20 | assertTrue(Hibernate.isInitialized(managedChildren)); | ||||||||||||||||||||||
22 | assertEquals(i2.getName(), "bar"); |
| 16 | assertTrue(Hibernate.isInitialized(managedChildren)); | ||||||||||||||||||||||
23 | Hibernate.initialize(i1); |
| 15 | Hibernate.initialize(managedChildren); | ||||||||||||||||||||||
24 | assertFalse(iter.hasNext()); |
| 27 | tx.commit(); | ||||||||||||||||||||||
25 | s.delete(i1); | | ||||||||||||||||||||||||
26 | s.delete(i2); | | ||||||||||||||||||||||||
27 | t.commit(); |
| 21 | tx.commit(); | ||||||||||||||||||||||
| 23 | assertUpdateCount(0); | ||||||||||||||||||||||||
|
| 25 | tx = s.beginTransaction(); | |||||||||||||||||||||||
28 | s.close(); | 28 | s.close(); | |||||||||||||||||||||||
29 | assertEquals(getSessions().getStatistics().getEntityFetchCount(), 2); |
| 24 | assertDeleteCount(0); |
Row | Violation |
---|---|
1 | Expression getSessions().getStatistics().clear() is a void method call, and thus it cannot be parameterized |
2 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
3 | Expression getSessions().getStatistics().clear() is a void method call, and thus it cannot be parameterized |
4 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
5 | Expression s.persist("Item",i1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression s.persist("Item",i1) is a void method call, and thus it cannot be parameterized |
7 | Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized |
8 | Expression s.persist("Item",i1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression s.persist("Item",i1) is a void method call, and thus it cannot be parameterized |
10 | Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized |
11 | Expression s.persist("Item",i2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression s.persist(root) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression s.persist("Item",i2) is a void method call, and thus it cannot be parameterized |
14 | Expression s.persist(root) is a void method call, and thus it cannot be parameterized |
15 | Unmatched statement Iterator iter=s.getNamedQuery("Item.nameDesc").iterate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched statement root=(NumberedNode)s.get(NumberedNode.class,root.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement i1=(Item)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Unmatched statement i2=(Item)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Expression assertFalse(Hibernate.isInitialized(i1)) is a void method call, and thus it cannot be parameterized |
20 | Expression assertSame(managedChildren,root.getChildren()) is a void method call, and thus it cannot be parameterized |
21 | Expression assertFalse(Hibernate.isInitialized(i1)) is a void method call, and thus it cannot be parameterized |
22 | Expression assertSame(managedChildren,root.getChildren()) is a void method call, and thus it cannot be parameterized |
23 | Expression assertSame(root,s.merge(newRoot)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression assertFalse(Hibernate.isInitialized(i2)) is a void method call, and thus it cannot be parameterized |
25 | Expression assertSame(root,s.merge(newRoot)) is a void method call, and thus it cannot be parameterized |
26 | Expression assertSame(root,s.merge(newRoot)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression assertFalse(Hibernate.isInitialized(i2)) is a void method call, and thus it cannot be parameterized |
28 | Expression assertSame(root,s.merge(newRoot)) is a void method call, and thus it cannot be parameterized |
29 | Expression assertFalse(Hibernate.isInitialized(i1)) is a void method call, and thus it cannot be parameterized |
30 | Expression cleanup() is a void method call, and thus it cannot be parameterized |
31 | Expression assertFalse(Hibernate.isInitialized(i1)) is a void method call, and thus it cannot be parameterized |
32 | Expression cleanup() is a void method call, and thus it cannot be parameterized |
33 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
34 | Expression assertFalse(Hibernate.isInitialized(i2)) is a void method call, and thus it cannot be parameterized |
35 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) is a void method call, and thus it cannot be parameterized |
36 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
37 | Expression assertFalse(Hibernate.isInitialized(i2)) is a void method call, and thus it cannot be parameterized |
38 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) is a void method call, and thus it cannot be parameterized |
39 | Expression assertEquals(i1.getName(),"foo") is a void method call, and thus it cannot be parameterized |
40 | Expression assertTrue(Hibernate.isInitialized(managedChildren)) is a void method call, and thus it cannot be parameterized |
41 | Expression assertEquals(i1.getName(),"foo") is a void method call, and thus it cannot be parameterized |
42 | Expression assertTrue(Hibernate.isInitialized(managedChildren)) is a void method call, and thus it cannot be parameterized |
43 | Expression assertEquals(i2.getName(),"bar") is a void method call, and thus it cannot be parameterized |
44 | Expression assertTrue(Hibernate.isInitialized(managedChildren)) is a void method call, and thus it cannot be parameterized |
45 | Expression assertEquals(i2.getName(),"bar") is a void method call, and thus it cannot be parameterized |
46 | Expression assertTrue(Hibernate.isInitialized(managedChildren)) is a void method call, and thus it cannot be parameterized |
47 | Type org.hibernate.test.iterate.Item of variable i1 does not match with type java.util.Set of variable managedChildren |
48 | Expression tx.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
49 | Expression assertFalse(iter.hasNext()) is a void method call, and thus it cannot be parameterized |
50 | Expression tx.commit() is a void method call, and thus it cannot be parameterized |
51 | Expression tx.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
52 | Expression assertFalse(iter.hasNext()) is a void method call, and thus it cannot be parameterized |
53 | Expression tx.commit() is a void method call, and thus it cannot be parameterized |
54 | Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
55 | Expression assertEquals(getSessions().getStatistics().getEntityFetchCount(),2) is a void method call, and thus it cannot be parameterized |
56 | Expression assertDeleteCount(0) is a void method call, and thus it cannot be parameterized |
57 | Expression assertEquals(getSessions().getStatistics().getEntityFetchCount(),2) is a void method call, and thus it cannot be parameterized |
58 | Expression assertDeleteCount(0) is a void method call, and thus it cannot be parameterized |