File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/orphan/OrphanTest.java | |||
Method name: void testImplicitSelectEntityAssociationInShallowQuery()
|
Method name: void testOrphanDeleteAfterPersistAndFlush()
|
|||
Number of AST nodes: 25 | Number of AST nodes: 24 | |||
1 | Session s = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | s.beginTransaction();↵ | 2 | ↵ | |
3 | SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation( "owner" );↵ | |||
4 | SimpleAssociatedEntity e1 = new SimpleAssociatedEntity( "thing one", owner );↵ | |||
5 | SimpleAssociatedEntity e2 = new SimpleAssociatedEntity( "thing two" );↵ | |||
6 | s.save( e1 );↵ | |||
7 | s.save( e2 );↵ | |||
8 | s.save( owner );↵ | |||
9 | s.getTransaction().commit();↵ | |||
10 | s.close();↵ | |||
11 | s = openSession();↵ | |||
12 | s.beginTransaction();↵ | |||
13 | int count = determineCount( s.createQuery( "select e.id, e.owner from SimpleAssociatedEntity e" ).list().iterator() );↵ | |||
14 | assertEquals( 1, count ); // thing two would be removed from the result due to the inner join↵ | |||
15 | count = determineCount( s.createQuery( "select e.id, e.owner from SimpleAssociatedEntity e" ).iterate() );↵ | |||
16 | assertEquals( 1, count );↵ | |||
17 | s.getTransaction()↵ | 3 | Transaction t = session.beginTransaction();↵ | |
4 | Product prod = new Product();↵ | |||
5 | prod.setName("Widget");↵ | |||
6 | Part part = new Part();↵ | |||
7 | part.setName("Widge");↵ | |||
8 | part.setDescription("part if a Widget");↵ | |||
9 | prod.getParts().add(part);↵ | |||
10 | Part part2 = new Part();↵ | |||
11 | part2.setName("Get");↵ | |||
12 | part2.setDescription("another part if a Widget");↵ | |||
13 | prod.getParts().add(part2);↵ | |||
14 | session.persist(prod);↵ | |||
15 | session.flush();↵ | |||
16 | ↵ | |||
17 | prod.getParts().remove(part);↵ | |||
18 | ↵ | |||
18 | .commit();↵ | 19 | t.commit();↵ | |
19 | s.close();↵ | 20 | session.close();↵ | |
21 | ↵ | |||
20 | s = openSession();↵ | 22 | session = openSession();↵ | |
21 | s.beginTransaction();↵ | 23 | t = session.beginTransaction();↵ | |
22 | s.delete( e1 );↵ | 24 | ↵ | |
23 | s.delete( e2↵ | 25 | assertNull( session.get(Part.class, "Widge") );↵ | |
24 | );↵ | 26 | assertNotNull( session.get(Part.class, "Get") );↵ | |
25 | s.delete( owner );↵ | 27 | session.delete( ↵ | |
26 | s.getTransaction()↵ | 28 | session.get(Product.class, "Widget") );↵ | |
27 | .commit();↵ | 29 | t.commit();↵ | |
28 | s.close(); | 30 | session.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 | 600 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 20 |
Number of unmapped statements in the second code fragment | 19 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); |
| 1 | Session session = openSession(); | ||||||||||||
|
| 2 | Transaction t = session.beginTransaction(); | |||||||||||||
2 | s.beginTransaction(); |
| | |||||||||||||
| 3 | Product prod = new Product(); | ||||||||||||||
3 | SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation("owner"); |
| | |||||||||||||
|
| 4 | prod.setName("Widget"); | |||||||||||||
4 | SimpleAssociatedEntity e1 = new SimpleAssociatedEntity("thing one", owner); |
| | |||||||||||||
| 5 | Part part = new Part(); | ||||||||||||||
5 | SimpleAssociatedEntity e2 = new SimpleAssociatedEntity("thing two"); |
| | |||||||||||||
|
| 6 | part.setName("Widge"); | |||||||||||||
6 | s.save(e1); |
| | |||||||||||||
|
| 7 | part.setDescription("part if a Widget"); | |||||||||||||
7 | s.save(e2); |
| | |||||||||||||
| 8 | prod.getParts().add(part); | ||||||||||||||
8 | s.save(owner); |
| | |||||||||||||
| 9 | Part part2 = new Part(); | ||||||||||||||
9 | s.getTransaction().commit(); |
| | |||||||||||||
|
| 10 | part2.setName("Get"); | |||||||||||||
|
| 11 | part2.setDescription("another part if a Widget"); | |||||||||||||
| 12 | prod.getParts().add(part2); | ||||||||||||||
|
| 13 | session.persist(prod); | |||||||||||||
|
| 14 | session.flush(); | |||||||||||||
| 15 | prod.getParts().remove(part); | ||||||||||||||
10 | s.close(); |
| 17 | session.close(); | ||||||||||||
11 | s = openSession(); |
| 18 | session = openSession(); | ||||||||||||
12 | s.beginTransaction(); |
| | |||||||||||||
13 | int count = determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").list().iterator()); |
| | |||||||||||||
14 | assertEquals(1, count); | | ||||||||||||||
15 | count = determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").iterate()); |
| | |||||||||||||
16 | assertEquals(1, count); | | ||||||||||||||
17 | s.getTransaction().commit(); |
| | |||||||||||||
|
| 19 | t = session.beginTransaction(); | |||||||||||||
|
| 20 | assertNull(session.get(Part.class, "Widge")); | |||||||||||||
18 | s.close(); |
| 24 | session.close(); | ||||||||||||
19 | s = openSession(); |
| | |||||||||||||
20 | s.beginTransaction(); | | ||||||||||||||
|
| 21 | assertNotNull(session.get(Part.class, "Get")); | |||||||||||||
21 | s.delete(e1); | | ||||||||||||||
|
| 22 | session.delete(session.get(Product.class, "Widget")); | |||||||||||||
22 | s.delete(e2); | | ||||||||||||||
23 | s.delete(owner); | | ||||||||||||||
24 | s.getTransaction().commit(); |
| 16 | t.commit(); | ||||||||||||
|
| 23 | t.commit(); | |||||||||||||
25 | s.close(); | |
Row | Violation |
---|---|
1 | Unmatched statement Transaction t=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement SimpleEntityWithAssociation owner=new SimpleEntityWithAssociation("owner"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement prod.setName("Widget"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement SimpleAssociatedEntity e1=new SimpleAssociatedEntity("thing one",owner); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement SimpleAssociatedEntity e2=new SimpleAssociatedEntity("thing two"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Unmatched statement part.setName("Widge"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
8 | Unmatched statement s.save(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement part.setDescription("part if a Widget"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
10 | Unmatched statement s.save(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
11 | Unmatched statement s.save(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | Unmatched statement part2.setName("Get"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
14 | Unmatched statement part2.setDescription("another part if a Widget"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
15 | Unmatched statement session.persist(prod); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched statement session.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Unmatched statement int count=determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").list().iterator()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement count=determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").iterate()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Unmatched statement t=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | Unmatched statement assertNull(session.get(Part.class,"Widge")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | Unmatched statement assertNotNull(session.get(Part.class,"Get")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Unmatched statement session.delete(session.get(Product.class,"Widget")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression t cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Unmatched statement t.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |