File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/orphan/OrphanTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/orphan/OrphanTest.java | |||
Method name: void testOrphanDeleteAfterLock()
|
Method name: void testOrphanDeleteOnMerge()
|
|||
Number of AST nodes: 28 | Number of AST nodes: 28 | |||
1 | Session session = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | Transaction t = session.beginTransaction();↵ | 2 | Transaction t = session.beginTransaction();↵ | |
3 | Product prod = new Product();↵ | 3 | Product prod = new Product();↵ | |
4 | prod.setName("Widget");↵ | 4 | prod.setName("Widget");↵ | |
5 | Part part = new Part();↵ | 5 | Part part = new Part();↵ | |
6 | part.setName("Widge");↵ | 6 | part.setName("Widge");↵ | |
7 | part.setDescription("part if a Widget");↵ | 7 | part.setDescription("part if a Widget");↵ | |
8 | prod.getParts().add(part);↵ | 8 | prod.getParts().add(part);↵ | |
9 | Part part2 = new Part();↵ | 9 | Part part2 = new Part();↵ | |
10 | part2.setName("Get");↵ | 10 | part2.setName("Get");↵ | |
11 | part2.setDescription("another part if a Widget");↵ | 11 | part2.setDescription("another part if a Widget");↵ | |
12 | prod.getParts().add(part2);↵ | 12 | prod.getParts().add(part2);↵ | |
13 | session.persist(prod);↵ | 13 | session.persist(prod);↵ | |
14 | t.commit();↵ | 14 | t.commit();↵ | |
15 | session.close();↵ | 15 | session.close();↵ | |
16 | ↵ | 16 | ↵ | |
17 | ↵ | 17 | prod.getParts().remove(part);↵ | |
18 | ↵ | |||
18 | session = openSession();↵ | 19 | session = openSession();↵ | |
19 | t = session.beginTransaction();↵ | 20 | t = session.beginTransaction();↵ | |
20 | session.lock(prod, LockMode.READ);↵ | 21 | session.↵ | |
21 | prod.getParts().remove(part);↵ | 22 | merge(prod);↵ | |
22 | t.commit();↵ | 23 | t.commit();↵ | |
23 | session.close();↵ | 24 | session.close();↵ | |
24 | ↵ | 25 | ↵ | |
25 | session = openSession();↵ | 26 | session = openSession();↵ | |
26 | t = session.beginTransaction();↵ | 27 | t = session.beginTransaction();↵ | |
27 | assertNull( session.get(Part.class, "Widge") );↵ | 28 | assertNull( session.get(Part.class, "Widge") );↵ | |
28 | assertNotNull( session.get(Part.class, "Get") );↵ | 29 | assertNotNull( session.get(Part.class, "Get") );↵ | |
29 | session.delete( session.get(Product.class, "Widget") );↵ | 30 | session.delete( session.get(Product.class, "Widget") );↵ | |
30 | t.commit();↵ | 31 | t.commit();↵ | |
31 | session.close(); | 32 |
| |
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 | 189 |
Number of mapped statements | 27 |
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 t = session.beginTransaction(); | 2 | Transaction t = session.beginTransaction(); | ||||||||||||||||||||||
3 | Product prod = new Product(); | 3 | Product prod = new Product(); | ||||||||||||||||||||||
4 | prod.setName("Widget"); | 4 | prod.setName("Widget"); | ||||||||||||||||||||||
5 | Part part = new Part(); | 5 | Part part = new Part(); | ||||||||||||||||||||||
6 | part.setName("Widge"); | 6 | part.setName("Widge"); | ||||||||||||||||||||||
7 | part.setDescription("part if a Widget"); | 7 | part.setDescription("part if a Widget"); | ||||||||||||||||||||||
8 | prod.getParts().add(part); | 8 | prod.getParts().add(part); | ||||||||||||||||||||||
9 | Part part2 = new Part(); | 9 | Part part2 = new Part(); | ||||||||||||||||||||||
10 | part2.setName("Get"); | 10 | part2.setName("Get"); | ||||||||||||||||||||||
11 | part2.setDescription("another part if a Widget"); | 11 | part2.setDescription("another part if a Widget"); | ||||||||||||||||||||||
12 | prod.getParts().add(part2); | 12 | prod.getParts().add(part2); | ||||||||||||||||||||||
13 | session.persist(prod); | 13 | session.persist(prod); | ||||||||||||||||||||||
14 | t.commit(); | 14 | t.commit(); | ||||||||||||||||||||||
15 | session.close(); | 15 | session.close(); | ||||||||||||||||||||||
16 | session = openSession(); | 17 | session = openSession(); | ||||||||||||||||||||||
17 | t = session.beginTransaction(); | 18 | t = session.beginTransaction(); | ||||||||||||||||||||||
|
| 19 | session.merge(prod); | ||||||||||||||||||||||
18 | session.lock(prod, LockMode.READ); |
| 26 | session.delete(session.get(Product.class, "Widget")); | |||||||||||||||||||||
19 | prod.getParts().remove(part); | 16 | prod.getParts().remove(part); | ||||||||||||||||||||||
20 | t.commit(); | 20 | t.commit(); | ||||||||||||||||||||||
21 | session.close(); | 21 | session.close(); | ||||||||||||||||||||||
22 | session = openSession(); | 22 | session = openSession(); | ||||||||||||||||||||||
23 | t = session.beginTransaction(); | 23 | t = session.beginTransaction(); | ||||||||||||||||||||||
24 | assertNull(session.get(Part.class, "Widge")); | 24 | assertNull(session.get(Part.class, "Widge")); | ||||||||||||||||||||||
25 | assertNotNull(session.get(Part.class, "Get")); | 25 | assertNotNull(session.get(Part.class, "Get")); | ||||||||||||||||||||||
26 | session.delete(session.get(Product.class, "Widget")); | | |||||||||||||||||||||||
27 | t.commit(); | 27 | t.commit(); | ||||||||||||||||||||||
28 | session.close(); | 28 | session.close(); |
Row | Violation |
---|---|
1 | Unmatched statement session.merge(prod); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Expression session.lock(prod,LockMode.READ) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression session.delete(session.get(Product.class,"Widget")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression session.lock(prod,LockMode.READ) is a void method call, and thus it cannot be parameterized |
5 | Expression session.delete(session.get(Product.class,"Widget")) is a void method call, and thus it cannot be parameterized |
6 | Expression session.lock(prod,LockMode.READ) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression session.delete(session.get(Product.class,"Widget")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression session.lock(prod,LockMode.READ) is a void method call, and thus it cannot be parameterized |
9 | Expression session.delete(session.get(Product.class,"Widget")) is a void method call, and thus it cannot be parameterized |
10 | Clone fragment #1 returns variables session , while Clone fragment #2 returns variables prod, session |