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/legacy/FooBarTest.java | |||
Method name: void testSelectClauseImplicitJoin()
|
Method name: void testCallback()
|
|||
Number of AST nodes: 29 | Number of AST nodes: 28 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction t = s.beginTransaction();↵ | 2 | ↵ | |
3 | Zoo zoo = new Zoo();↵ | |||
4 | zoo.setName("The Zoo"↵ | 3 | Qux q = new Qux("0");↵ | |
5 | );↵ | 4 | s.save(q);↵ | |
6 | zoo.setMammals( new HashMap() );↵ | 5 | q.set↵ | |
7 | zoo.setAnimals( new HashMap() );↵ | |||
8 | Mammal plat = new Mammal();↵ | |||
9 | plat.setBodyWeight( 11f );↵ | |||
10 | plat.setDescription( "Platypus" );↵ | |||
11 | plat.setZoo(zoo);↵ | |||
12 | plat.setSerialNumber("plat123");↵ | |||
13 | zoo.getMammals().put("Platypus", plat);↵ | |||
14 | zoo.getAnimals().put("plat123", plat);↵ | |||
15 | s.persist( plat );↵ | |||
16 | s.persist(zoo);↵ | |||
17 | s.flush();↵ | |||
18 | s.clear();↵ | |||
19 | Query q = s.createQuery("select distinct a.zoo from Animal a where a.zoo is not null");↵ | |||
20 | Type type = q.getReturnTypes()[0];↵ | |||
21 | assertTrue( type instanceof ManyToOneType );↵ | |||
22 | assertEquals( ( (ManyToOneType) type ).getAssociatedEntityName(), "org.hibernate.test.hql.Zoo" );↵ | |||
23 | zoo = (Zoo) q.list()↵ | 6 | Child( new Qux("1") );↵ | |
7 | s.save( q.getChild() );↵ | |||
8 | Qux q2 = new Qux("2");↵ | |||
9 | q2.setChild( q.getChild() );↵ | |||
10 | Qux q3 = new Qux("3");↵ | |||
11 | q.getChild().setChild(q3);↵ | |||
12 | s.save(q3);↵ | |||
13 | Qux q4 = new Qux("4");↵ | |||
14 | q4.setChild(q3);↵ | |||
15 | s.save(q4);↵ | |||
16 | s.save(q2);↵ | |||
17 | s.flush();↵ | |||
18 | s.connection().commit();↵ | |||
19 | s.close();↵ | |||
20 | s = openSession();↵ | |||
21 | List l = s.find("from Qux");↵ | |||
22 | assertTrue( "", l.size()==5);↵ | |||
24 | .get(0);↵ | 23 | s.delete( l.get(0) );↵ | |
25 | assertEquals( zoo.getMammals().size(), 1 );↵ | 24 | ↵ | |
26 | assertEquals( zoo.getAnimals().size(), 1 );↵ | |||
27 | s.clear(↵ | 25 | s.delete( l.get(1) );↵ | |
26 | s.delete( l.get(2) );↵ | |||
28 | );↵ | 27 | s.delete( l.get(3) );↵ | |
29 | s.delete(plat);↵ | 28 | s.delete(↵ | |
30 | s.delete(zoo);↵ | |||
31 | t↵ | 29 | l.get(4) );↵ | |
30 | s.flush();↵ | |||
32 | .commit();↵ | 31 | s.connection().commit();↵ | |
33 | s.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 in different classes having the same super class |
Number of node comparisons | 812 |
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 25 |
Number of unmapped statements in the second code fragment | 24 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); |
| 1 | Session s = openSession(); | ||||||||||||||
|
| 2 | Qux q = new Qux("0"); | |||||||||||||||
2 | Transaction t = s.beginTransaction(); |
| | |||||||||||||||
|
| 3 | s.save(q); | |||||||||||||||
3 | Zoo zoo = new Zoo(); | | ||||||||||||||||
|
| 4 | q.setChild(new Qux("1")); | |||||||||||||||
4 | zoo.setName("The Zoo"); |
| | |||||||||||||||
|
| 5 | s.save(q.getChild()); | |||||||||||||||
5 | zoo.setMammals(new HashMap()); |
| | |||||||||||||||
|
| 6 | Qux q2 = new Qux("2"); | |||||||||||||||
6 | zoo.setAnimals(new HashMap()); |
| | |||||||||||||||
|
| 7 | q2.setChild(q.getChild()); | |||||||||||||||
7 | Mammal plat = new Mammal(); | | ||||||||||||||||
|
| 8 | Qux q3 = new Qux("3"); | |||||||||||||||
8 | plat.setBodyWeight(11f); |
| | |||||||||||||||
|
| 9 | q.getChild().setChild(q3); | |||||||||||||||
9 | plat.setDescription("Platypus"); |
| | |||||||||||||||
|
| 10 | s.save(q3); | |||||||||||||||
10 | plat.setZoo(zoo); |
| | |||||||||||||||
|
| 11 | Qux q4 = new Qux("4"); | |||||||||||||||
11 | plat.setSerialNumber("plat123"); |
| | |||||||||||||||
|
| 12 | q4.setChild(q3); | |||||||||||||||
12 | zoo.getMammals().put("Platypus", plat); | | ||||||||||||||||
|
| 13 | s.save(q4); | |||||||||||||||
13 | zoo.getAnimals().put("plat123", plat); | | ||||||||||||||||
|
| 14 | s.save(q2); | |||||||||||||||
14 | s.persist(plat); |
| | |||||||||||||||
15 | s.persist(zoo); |
| | |||||||||||||||
16 | s.flush(); |
| 15 | s.flush(); | ||||||||||||||
|
| 16 | s.connection().commit(); | |||||||||||||||
17 | s.clear(); |
| | |||||||||||||||
|
| 18 | s = openSession(); | |||||||||||||||
18 | Query q = s.createQuery("select distinct a.zoo from Animal a where a.zoo is not null"); |
| | |||||||||||||||
|
| 19 | List l = s.find("from Qux"); | |||||||||||||||
19 | Type type = q.getReturnTypes()[0]; | | ||||||||||||||||
20 | assertTrue(type instanceof ManyToOneType); |
| 20 | assertTrue("", l.size() == 5); | ||||||||||||||
| 21 | s.delete(l.get(0)); | ||||||||||||||||
21 | assertEquals(((ManyToOneType)type).getAssociatedEntityName(), "org.hibernate.test.hql.Zoo"); | | ||||||||||||||||
| 22 | s.delete(l.get(1)); | ||||||||||||||||
22 | zoo = (Zoo)q.list().get(0); |
| | |||||||||||||||
| 23 | s.delete(l.get(2)); | ||||||||||||||||
23 | assertEquals(zoo.getMammals().size(), 1); | | ||||||||||||||||
| 24 | s.delete(l.get(3)); | ||||||||||||||||
24 | assertEquals(zoo.getAnimals().size(), 1); | | ||||||||||||||||
| 25 | s.delete(l.get(4)); | ||||||||||||||||
25 | s.clear(); |
| | |||||||||||||||
| 26 | s.flush(); | ||||||||||||||||
26 | s.delete(plat); |
| | |||||||||||||||
| 27 | s.connection().commit(); | ||||||||||||||||
27 | s.delete(zoo); |
| | |||||||||||||||
| 28 | s.close(); | ||||||||||||||||
28 | t.commit(); |
| | |||||||||||||||
29 | s.close(); |
| 17 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement Qux q=new Qux("0"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement Transaction t=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 s.save(q); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement q.setChild(new Qux("1")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement zoo.setName("The Zoo"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement s.save(q.getChild()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement zoo.setMammals(new HashMap()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
8 | Unmatched statement Qux q2=new Qux("2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
9 | Unmatched statement zoo.setAnimals(new HashMap()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
10 | Unmatched statement q2.setChild(q.getChild()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
11 | Unmatched statement Qux q3=new Qux("3"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
12 | Unmatched statement plat.setBodyWeight(11f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
13 | Unmatched statement q.getChild().setChild(q3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
14 | Unmatched statement plat.setDescription("Platypus"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
15 | Unmatched statement s.save(q3); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched statement plat.setZoo(zoo); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
17 | Unmatched statement Qux q4=new Qux("4"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
18 | Unmatched statement plat.setSerialNumber("plat123"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
19 | Unmatched statement q4.setChild(q3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
20 | Unmatched statement s.save(q4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Unmatched statement s.save(q2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | Unmatched statement s.persist(plat); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | Unmatched statement s.persist(zoo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
27 | Unmatched statement Query q=s.createQuery("select distinct a.zoo from Animal a where a.zoo is not null"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
28 | Unmatched statement List l=s.find("from Qux"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
29 | Expression assertTrue(type instanceof ManyToOneType) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression assertTrue("",l.size() == 5) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
31 | Expression assertTrue(type instanceof ManyToOneType) is a void method call, and thus it cannot be parameterized |
32 | Expression assertTrue("",l.size() == 5) is a void method call, and thus it cannot be parameterized |
33 | Unmatched statement zoo=(Zoo)q.list().get(0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
34 | Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
35 | Unmatched statement s.delete(plat); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
36 | Unmatched statement s.delete(zoo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
37 | Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
38 | Clone fragment #1 returns variable s with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session |