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 | 8 |
Number of unmapped statements in the first code fragment | 21 |
Number of unmapped statements in the second code fragment | 20 |
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 | 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 | Mammal plat = new Mammal(); | | ||||||||||||||||||||||||
| 8 | Qux q3 = new Qux("3"); | ||||||||||||||||||||||||
8 | plat.setBodyWeight(11f); | | ||||||||||||||||||||||||
9 | plat.setDescription("Platypus"); | | ||||||||||||||||||||||||
10 | plat.setZoo(zoo); | | ||||||||||||||||||||||||
11 | plat.setSerialNumber("plat123"); | | ||||||||||||||||||||||||
12 | zoo.getMammals().put("Platypus", plat); | | ||||||||||||||||||||||||
13 | zoo.getAnimals().put("plat123", plat); | | ||||||||||||||||||||||||
14 | s.persist(plat); | | ||||||||||||||||||||||||
15 | s.persist(zoo); | | ||||||||||||||||||||||||
16 | s.flush(); |
| 15 | s.flush(); | ||||||||||||||||||||||
17 | s.clear(); |
| 20 | assertTrue("", l.size() == 5); | ||||||||||||||||||||||
18 | Query q = s.createQuery("select distinct a.zoo from Animal a where a.zoo is not null"); | | ||||||||||||||||||||||||
19 | Type type = q.getReturnTypes()[0]; | | ||||||||||||||||||||||||
20 | assertTrue(type instanceof ManyToOneType); |
| 4 | q.setChild(new Qux("1")); | ||||||||||||||||||||||
21 | assertEquals(((ManyToOneType)type).getAssociatedEntityName(), "org.hibernate.test.hql.Zoo"); |
| 12 | q4.setChild(q3); | ||||||||||||||||||||||
22 | zoo = (Zoo)q.list().get(0); | | ||||||||||||||||||||||||
23 | assertEquals(zoo.getMammals().size(), 1); |
| 9 | q.getChild().setChild(q3); | ||||||||||||||||||||||
24 | assertEquals(zoo.getAnimals().size(), 1); |
| 7 | q2.setChild(q.getChild()); | ||||||||||||||||||||||
| 10 | s.save(q3); | ||||||||||||||||||||||||
| 11 | Qux q4 = new Qux("4"); | ||||||||||||||||||||||||
| 13 | s.save(q4); | ||||||||||||||||||||||||
| 14 | s.save(q2); | ||||||||||||||||||||||||
| 16 | s.connection().commit(); | ||||||||||||||||||||||||
|
| 18 | s = openSession(); | |||||||||||||||||||||||
| 19 | List l = s.find("from Qux"); | ||||||||||||||||||||||||
| 21 | s.delete(l.get(0)); | ||||||||||||||||||||||||
| 22 | s.delete(l.get(1)); | ||||||||||||||||||||||||
| 23 | s.delete(l.get(2)); | ||||||||||||||||||||||||
| 24 | s.delete(l.get(3)); | ||||||||||||||||||||||||
| 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 | t.commit(); | | ||||||||||||||||||||||||
29 | s.close(); |
| 17 | s.close(); | ||||||||||||||||||||||
| 28 | s.close(); |
Row | Violation |
---|---|
1 | 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 |
2 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
3 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
4 | Expression assertTrue("",l.size() == 5) is a void method call, and thus it cannot be parameterized |
5 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
6 | Expression assertTrue("",l.size() == 5) is a void method call, and thus it cannot be parameterized |
7 | Expression assertTrue(type instanceof ManyToOneType) is a void method call, and thus it cannot be parameterized |
8 | Expression q.setChild(new Qux("1")) is a void method call, and thus it cannot be parameterized |
9 | Expression assertTrue(type instanceof ManyToOneType) is a void method call, and thus it cannot be parameterized |
10 | Expression q.setChild(new Qux("1")) is a void method call, and thus it cannot be parameterized |
11 | Expression assertEquals(((ManyToOneType)type).getAssociatedEntityName(),"org.hibernate.test.hql.Zoo") is a void method call, and thus it cannot be parameterized |
12 | Expression q4.setChild(q3) is a void method call, and thus it cannot be parameterized |
13 | Expression assertEquals(((ManyToOneType)type).getAssociatedEntityName(),"org.hibernate.test.hql.Zoo") is a void method call, and thus it cannot be parameterized |
14 | Expression q4.setChild(q3) is a void method call, and thus it cannot be parameterized |
15 | Expression q.getChild().setChild(q3) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression assertEquals(zoo.getMammals().size(),1) is a void method call, and thus it cannot be parameterized |
17 | Expression q.getChild().setChild(q3) is a void method call, and thus it cannot be parameterized |
18 | Expression q.getChild().setChild(q3) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression assertEquals(zoo.getMammals().size(),1) is a void method call, and thus it cannot be parameterized |
20 | Expression q.getChild().setChild(q3) is a void method call, and thus it cannot be parameterized |
21 | Expression assertEquals(zoo.getAnimals().size(),1) is a void method call, and thus it cannot be parameterized |
22 | Expression q2.setChild(q.getChild()) is a void method call, and thus it cannot be parameterized |
23 | Expression assertEquals(zoo.getAnimals().size(),1) is a void method call, and thus it cannot be parameterized |
24 | Expression q2.setChild(q.getChild()) is a void method call, and thus it cannot be parameterized |
25 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
27 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
28 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
29 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |