File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/extralazy/ExtraLazyTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/map/MapIndexFormulaTest.java | |||
Method name: void testIndexFormulaMap()
|
Method name: void testIndexFormulaMap()
|
|||
Number of AST nodes: 46 | Number of AST nodes: 46 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction t = s.beginTransaction();↵ | 2 | Transaction t = s.beginTransaction();↵ | |
3 | User gavin = new User("gavin", "secret");↵ | 3 | User gavin = new User("gavin", "secret");↵ | |
4 | User turin = new User("turin", "tiger");↵ | 4 | User turin = new User("turin", "tiger");↵ | |
5 | Group g = new Group("developers");↵ | 5 | Group g = new Group("developers");↵ | |
6 | g.getUsers().put("gavin", gavin);↵ | 6 | g.getUsers().put("gavin", gavin);↵ | |
7 | g.getUsers().put("turin", turin);↵ | 7 | g.getUsers().put("turin", turin);↵ | |
8 | s.persist(g);↵ | 8 | s.persist(g);↵ | |
9 | gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );↵ | 9 | gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );↵ | |
10 | gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") );↵ | 10 | gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") );↵ | |
11 | t.commit();↵ | 11 | t.commit();↵ | |
12 | s.close();↵ | 12 | s.close();↵ | |
13 | ↵ | 13 | ↵ | |
14 | s = openSession();↵ | 14 | s = openSession();↵ | |
15 | t = s.beginTransaction();↵ | 15 | t = s.beginTransaction();↵ | |
16 | g = (Group) s.get(Group.class, "developers");↵ | 16 | g = (Group) s.get(Group.class, "developers");↵ | |
17 | assertEquals( g.getUsers().size(), 2 );↵ | 17 | assertEquals( g.getUsers().size(), 2 );↵ | |
18 | g.getUsers().remove("turin");↵ | 18 | g.getUsers().remove("turin");↵ | |
19 | Map smap = ( (User) g.getUsers().get("gavin") ).getSession();↵ | 19 | Map smap = ( (User) g.getUsers().get("gavin") ).getSession();↵ | |
20 | assertEquals(smap.size(), 2);↵ | 20 | assertEquals(smap.size(), 2);↵ | |
21 | smap.remove("bar");↵ | 21 | smap.remove("bar");↵ | |
22 | t.commit();↵ | 22 | t.commit();↵ | |
23 | s.close();↵ | 23 | s.close();↵ | |
24 | s = openSession();↵ | 24 | s = openSession();↵ | |
25 | t = s.beginTransaction();↵ | 25 | t = s.beginTransaction();↵ | |
26 | g = (Group) s.get(Group.class, "developers");↵ | 26 | g = (Group) s.get(Group.class, "developers");↵ | |
27 | assertEquals( g.getUsers().size(), 1 );↵ | 27 | assertEquals( g.getUsers().size(), 1 );↵ | |
28 | smap = ( (User) g.getUsers().get("gavin") ).getSession();↵ | 28 | smap = ( (User) g.getUsers().get("gavin") ).getSession();↵ | |
29 | assertEquals(smap.size(), 1);↵ | 29 | assertEquals(smap.size(), 1);↵ | |
30 | gavin = (User) g.getUsers().put("gavin", turin);↵ | 30 | gavin = (User) g.getUsers().put("gavin", turin);↵ | |
31 | s.delete(gavin);↵ | 31 | s.delete(gavin);↵ | |
32 | assertEquals( s.createQuery("select count(*) from SessionAttribute").uniqueResult(), new Long(0) );↵ | 32 | assertEquals( s.createQuery("select count(*) from SessionAttribute").uniqueResult(), new Long(0) );↵ | |
33 | t.commit();↵ | 33 | t.commit();↵ | |
34 | s.close();↵ | 34 | s.close();↵ | |
35 | s = openSession();↵ | 35 | s = openSession();↵ | |
36 | t = s.beginTransaction();↵ | 36 | t = s.beginTransaction();↵ | |
37 | g = (Group) s.get(Group.class, "developers");↵ | 37 | g = (Group) s.get(Group.class, "developers");↵ | |
38 | assertEquals( g.getUsers().size(), 1 );↵ | 38 | assertEquals( g.getUsers().size(), 1 );↵ | |
39 | turin = (User) g.getUsers().get("turin");↵ | 39 | turin = (User) g.getUsers().get("turin");↵ | |
40 | smap = turin.getSession();↵ | 40 | smap = turin.getSession();↵ | |
41 | assertEquals(smap.size(), 0);↵ | 41 | assertEquals(smap.size(), 0);↵ | |
42 | assertEquals( s.createQuery("select count(*) from User").uniqueResult(), new Long(1) );↵ | 42 | assertEquals( s.createQuery("select count(*) from User").uniqueResult(), new Long(1) );↵ | |
43 | s.delete(g);↵ | 43 | s.delete(g);↵ | |
44 | s.delete(turin);↵ | 44 | s.delete(turin);↵ | |
45 | assertEquals( s.createQuery("select count(*) from User").uniqueResult(), new Long(0) );↵ | 45 | assertEquals( s.createQuery("select count(*) from User").uniqueResult(), new Long(0) );↵ | |
46 | t.commit();↵ | 46 | t.commit();↵ | |
47 | s.close(); | 47 |
| |
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 | 919 |
Number of mapped statements | 38 |
Number of unmapped statements in the first code fragment | 8 |
Number of unmapped statements in the second code fragment | 8 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 1 | Session s = openSession(); | ||||||||||||||||||
2 | Transaction t = s.beginTransaction(); | 2 | Transaction t = s.beginTransaction(); | ||||||||||||||||||
|
| 3 | User gavin = new User("gavin", "secret"); | ||||||||||||||||||
3 | User gavin = new User("gavin", "secret"); |
| | ||||||||||||||||||
|
| 4 | User turin = new User("turin", "tiger"); | ||||||||||||||||||
4 | User turin = new User("turin", "tiger"); |
| | ||||||||||||||||||
|
| 5 | Group g = new Group("developers"); | ||||||||||||||||||
5 | Group g = new Group("developers"); |
| | ||||||||||||||||||
6 | g.getUsers().put("gavin", gavin); |
| 6 | g.getUsers().put("gavin", gavin); | |||||||||||||||||
7 | g.getUsers().put("turin", turin); |
| 7 | g.getUsers().put("turin", turin); | |||||||||||||||||
8 | s.persist(g); |
| 8 | s.persist(g); | |||||||||||||||||
9 | gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz")); |
| 9 | gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz")); | |||||||||||||||||
10 | gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2")); |
| 10 | gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2")); | |||||||||||||||||
11 | t.commit(); | 11 | t.commit(); | ||||||||||||||||||
12 | s.close(); | 12 | s.close(); | ||||||||||||||||||
13 | s = openSession(); | 13 | s = openSession(); | ||||||||||||||||||
14 | t = s.beginTransaction(); | 14 | t = s.beginTransaction(); | ||||||||||||||||||
|
| 15 | g = (Group)s.get(Group.class, "developers"); | ||||||||||||||||||
15 | g = (Group)s.get(Group.class, "developers"); |
| | ||||||||||||||||||
16 | assertEquals(g.getUsers().size(), 2); |
| 16 | assertEquals(g.getUsers().size(), 2); | |||||||||||||||||
17 | g.getUsers().remove("turin"); |
| 17 | g.getUsers().remove("turin"); | |||||||||||||||||
18 | Map smap = ((User)g.getUsers().get("gavin")).getSession(); |
| 18 | Map smap = ((User)g.getUsers().get("gavin")).getSession(); | |||||||||||||||||
19 | assertEquals(smap.size(), 2); | 19 | assertEquals(smap.size(), 2); | ||||||||||||||||||
20 | smap.remove("bar"); | 20 | smap.remove("bar"); | ||||||||||||||||||
21 | t.commit(); | 21 | t.commit(); | ||||||||||||||||||
22 | s.close(); | 22 | s.close(); | ||||||||||||||||||
23 | s = openSession(); | 23 | s = openSession(); | ||||||||||||||||||
24 | t = s.beginTransaction(); | 24 | t = s.beginTransaction(); | ||||||||||||||||||
|
| 25 | g = (Group)s.get(Group.class, "developers"); | ||||||||||||||||||
25 | g = (Group)s.get(Group.class, "developers"); |
| | ||||||||||||||||||
26 | assertEquals(g.getUsers().size(), 1); |
| 26 | assertEquals(g.getUsers().size(), 1); | |||||||||||||||||
27 | smap = ((User)g.getUsers().get("gavin")).getSession(); |
| 27 | smap = ((User)g.getUsers().get("gavin")).getSession(); | |||||||||||||||||
28 | assertEquals(smap.size(), 1); | 28 | assertEquals(smap.size(), 1); | ||||||||||||||||||
|
| 29 | gavin = (User)g.getUsers().put("gavin", turin); | ||||||||||||||||||
29 | gavin = (User)g.getUsers().put("gavin", turin); |
| | ||||||||||||||||||
30 | s.delete(gavin); |
| 30 | s.delete(gavin); | |||||||||||||||||
31 | assertEquals(s.createQuery("select count(*) from SessionAttribute").uniqueResult(), new Long(0)); | 31 | assertEquals(s.createQuery("select count(*) from SessionAttribute").uniqueResult(), new Long(0)); | ||||||||||||||||||
32 | t.commit(); | 32 | t.commit(); | ||||||||||||||||||
33 | s.close(); | 33 | s.close(); | ||||||||||||||||||
34 | s = openSession(); | 34 | s = openSession(); | ||||||||||||||||||
35 | t = s.beginTransaction(); | 35 | t = s.beginTransaction(); | ||||||||||||||||||
|
| 36 | g = (Group)s.get(Group.class, "developers"); | ||||||||||||||||||
36 | g = (Group)s.get(Group.class, "developers"); |
| | ||||||||||||||||||
37 | assertEquals(g.getUsers().size(), 1); |
| 37 | assertEquals(g.getUsers().size(), 1); | |||||||||||||||||
|
| 38 | turin = (User)g.getUsers().get("turin"); | ||||||||||||||||||
38 | turin = (User)g.getUsers().get("turin"); |
| | ||||||||||||||||||
39 | smap = turin.getSession(); |
| 39 | smap = turin.getSession(); | |||||||||||||||||
40 | assertEquals(smap.size(), 0); | 40 | assertEquals(smap.size(), 0); | ||||||||||||||||||
41 | assertEquals(s.createQuery("select count(*) from User").uniqueResult(), new Long(1)); | 41 | assertEquals(s.createQuery("select count(*) from User").uniqueResult(), new Long(1)); | ||||||||||||||||||
42 | s.delete(g); |
| 42 | s.delete(g); | |||||||||||||||||
43 | s.delete(turin); |
| 43 | s.delete(turin); | |||||||||||||||||
44 | assertEquals(s.createQuery("select count(*) from User").uniqueResult(), new Long(0)); | 44 | assertEquals(s.createQuery("select count(*) from User").uniqueResult(), new Long(0)); | ||||||||||||||||||
45 | t.commit(); | 45 | t.commit(); | ||||||||||||||||||
46 | s.close(); | 46 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement User gavin=new User("gavin","secret"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement User gavin=new User("gavin","secret"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement User turin=new User("turin","tiger"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement User turin=new User("turin","tiger"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement Group g=new Group("developers"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement Group g=new Group("developers"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
8 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
9 | Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.map.User of variable turin |
10 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
11 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
12 | Type org.hibernate.test.extralazy.SessionAttribute does not match with type org.hibernate.test.map.SessionAttribute |
13 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
14 | Type org.hibernate.test.extralazy.SessionAttribute does not match with type org.hibernate.test.map.SessionAttribute |
15 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
16 | Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
19 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
20 | Expression (User)g.getUsers().get("gavin") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression (User)g.getUsers().get("gavin") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Type org.hibernate.test.extralazy.User does not match with type org.hibernate.test.map.User |
23 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
24 | Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
27 | Expression (User)g.getUsers().get("gavin") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression (User)g.getUsers().get("gavin") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Type org.hibernate.test.extralazy.User does not match with type org.hibernate.test.map.User |
30 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
31 | Unmatched statement gavin=(User)g.getUsers().put("gavin",turin); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
32 | Unmatched statement gavin=(User)g.getUsers().put("gavin",turin); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
33 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
34 | Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
35 | Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
36 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
37 | Unmatched statement turin=(User)g.getUsers().get("turin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
38 | Unmatched statement turin=(User)g.getUsers().get("turin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
39 | Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.map.User of variable turin |
40 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.map.Group of variable g |
41 | Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.map.User of variable turin |