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/ops/MergeTest.java | |||
Method name: void testImplicitJoinsInDifferentClauses()
|
Method name: void testMergeTree()
|
|||
Number of AST nodes: 21 | Number of AST nodes: 23 | |||
1 | clearCounts();↵ | |||
1 | Session s = openSession();↵ | 2 | Session s = openSession();↵ | |
2 | s.beginTransaction();↵ | 3 | Transaction↵ | |
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 | checkCounts( "select e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause" ↵ | 4 | tx = s.beginTransaction();↵ | |
5 | Node root = new Node("root");↵ | |||
6 | Node child = new Node("child");↵ | |||
7 | root.addChild(child);↵ | |||
8 | s.persist(root);↵ | |||
9 | tx.commit();↵ | |||
10 | s.close();↵ | |||
12 | );↵ | 11 | assertInsertCount(2);↵ | |
13 | checkCounts( "select e.id, e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause" );↵ | 12 | clearCounts(↵ | |
14 | // resolved to a "id short cut" when part of the order by clause -> no inner join = no weeding out...↵ | |||
15 | checkCounts( "from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause" ↵ | 13 | );↵ | |
14 | root.setDescription("The root node");↵ | |||
16 | );↵ | 15 | child.setDescription("The child node");↵ | |
17 | // resolved to a "id short cut" when part of the group by clause -> no inner join = no weeding out...↵ | 16 | ↵ | |
18 | checkCounts( "select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses" ↵ | 17 | Node secondChild = new Node("second child");↵ | |
19 | );↵ | 18 | root.addChild(secondChild);↵ | |
20 | s = openSession();↵ | 19 | s = openSession();↵ | |
21 | s.beginTransaction();↵ | 20 | tx = s.beginTransaction();↵ | |
22 | s.delete( e1 );↵ | 21 | s.↵ | |
23 | s.delete( e2 );↵ | |||
24 | s.delete( owner ↵ | 22 | merge(root);↵ | |
23 | tx.commit();↵ | |||
25 | );↵ | 24 | s.close();↵ | |
26 | s.getTransaction().commi↵ | 25 | assertInsertCount(1);↵ | |
27 | t();↵ | 26 | assertUpdateCount(2);↵ | |
28 | s.close(); | 27 | 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 | 403 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 13 |
Number of unmapped statements in the second code fragment | 15 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 2 | Session s = openSession(); | ||||||||||||||||||
2 | s.beginTransaction(); |
| | ||||||||||||||||||
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(); | 9 | s.close(); | ||||||||||||||||||
11 | checkCounts("select e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause"); |
| 11 | clearCounts(); | |||||||||||||||||
12 | checkCounts("select e.id, e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause"); |
| 1 | clearCounts(); | |||||||||||||||||
|
| 3 | Transaction tx = s.beginTransaction(); | ||||||||||||||||||
|
| 4 | Node root = new Node("root"); | ||||||||||||||||||
|
| 5 | Node child = new Node("child"); | ||||||||||||||||||
|
| 6 | root.addChild(child); | ||||||||||||||||||
|
| 7 | s.persist(root); | ||||||||||||||||||
|
| 8 | tx.commit(); | ||||||||||||||||||
|
| 12 | root.setDescription("The root node"); | ||||||||||||||||||
|
| 13 | child.setDescription("The child node"); | ||||||||||||||||||
|
| 14 | Node secondChild = new Node("second child"); | ||||||||||||||||||
|
| 15 | root.addChild(secondChild); | ||||||||||||||||||
|
| 17 | tx = s.beginTransaction(); | ||||||||||||||||||
|
| 18 | s.merge(root); | ||||||||||||||||||
|
| 19 | tx.commit(); | ||||||||||||||||||
| 21 | assertInsertCount(1); | |||||||||||||||||||
| 22 | assertUpdateCount(2); | |||||||||||||||||||
13 | checkCounts("from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause"); |
| 23 | cleanup(); | |||||||||||||||||
14 | checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses"); |
| 10 | assertInsertCount(2); | |||||||||||||||||
15 | s = openSession(); | 16 | s = openSession(); | ||||||||||||||||||
16 | s.beginTransaction(); |
| | ||||||||||||||||||
17 | s.delete(e1); |
| | ||||||||||||||||||
18 | s.delete(e2); |
| | ||||||||||||||||||
19 | s.delete(owner); |
| | ||||||||||||||||||
20 | s.getTransaction().commit(); |
| | ||||||||||||||||||
21 | s.close(); | 20 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | 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 |
3 | 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 |
4 | 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 |
5 | 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 |
6 | 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 |
7 | 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 |
8 | 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 |
9 | Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized |
10 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
11 | Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized |
12 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
13 | Expression checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized |
14 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
15 | Expression checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized |
16 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
17 | Unmatched statement Transaction tx=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 Node root=new Node("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
19 | Unmatched statement Node child=new Node("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
20 | Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
21 | Unmatched statement s.persist(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
23 | Unmatched statement root.setDescription("The root node"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
24 | Unmatched statement child.setDescription("The child node"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
25 | Unmatched statement Node secondChild=new Node("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
26 | Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
27 | 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 |
28 | Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
29 | Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
30 | Expression checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause") is a void method call, and thus it cannot be parameterized |
31 | Expression cleanup() is a void method call, and thus it cannot be parameterized |
32 | Expression checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause") is a void method call, and thus it cannot be parameterized |
33 | Expression cleanup() is a void method call, and thus it cannot be parameterized |
34 | Expression checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses") is a void method call, and thus it cannot be parameterized |
35 | Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized |
36 | Expression checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses") is a void method call, and thus it cannot be parameterized |
37 | Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized |
38 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
39 | Unmatched statement s.delete(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
40 | Unmatched statement s.delete(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
41 | Unmatched statement s.delete(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
42 | 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 |
43 | Clone fragment #1 returns variables s , while Clone fragment #2 returns variables |