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 testMergeTreeWithGeneratedId()
|
|||
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 | NumberedNode root = new NumberedNode("root");↵ | |||
6 | NumberedNode child = new NumberedNode("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 | NumberedNode secondChild = new NumberedNode("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 | 11 |
Number of unmapped statements in the first code fragment | 10 |
Number of unmapped statements in the second code fragment | 12 |
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(); |
| 8 | tx.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 | NumberedNode root = new NumberedNode("root"); | ||||||||||||||||||||||||
| 5 | NumberedNode child = new NumberedNode("child"); | ||||||||||||||||||||||||
| 6 | root.addChild(child); | ||||||||||||||||||||||||
|
| 7 | s.persist(root); | |||||||||||||||||||||||
13 | checkCounts("from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause"); |
| 10 | assertInsertCount(2); | ||||||||||||||||||||||
| 12 | root.setDescription("The root node"); | ||||||||||||||||||||||||
| 13 | child.setDescription("The child node"); | ||||||||||||||||||||||||
| 14 | NumberedNode secondChild = new NumberedNode("second child"); | ||||||||||||||||||||||||
| 15 | root.addChild(secondChild); | ||||||||||||||||||||||||
14 | checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses"); |
| 21 | assertInsertCount(1); | ||||||||||||||||||||||
15 | s = openSession(); | 16 | s = openSession(); | |||||||||||||||||||||||
16 | s.beginTransaction(); | | ||||||||||||||||||||||||
|
| 17 | tx = s.beginTransaction(); | |||||||||||||||||||||||
| 18 | s.merge(root); | ||||||||||||||||||||||||
| 22 | assertUpdateCount(2); | ||||||||||||||||||||||||
17 | s.delete(e1); |
| 23 | cleanup(); | ||||||||||||||||||||||
18 | s.delete(e2); | | ||||||||||||||||||||||||
19 | s.delete(owner); | | ||||||||||||||||||||||||
20 | s.getTransaction().commit(); |
| 19 | tx.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 s.save(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | 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 |
4 | 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 |
5 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | 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 |
7 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
8 | 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 |
9 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
10 | 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 |
11 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
12 | 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 |
13 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
14 | 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 |
15 | 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 |
16 | 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 |
17 | Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized |
18 | 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 |
19 | Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized |
20 | 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 |
21 | Expression assertInsertCount(1) is a void method call, and thus it cannot be parameterized |
22 | 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 |
23 | Expression assertInsertCount(1) is a void method call, and thus it cannot be parameterized |
24 | 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 |
25 | Expression s.delete(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression s.delete(e1) is a void method call, and thus it cannot be parameterized |
27 | Expression cleanup() is a void method call, and thus it cannot be parameterized |
28 | Expression s.delete(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression s.delete(e1) 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 s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |