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 testSQLQuery()
|
Method name: void testSQLQuery()
|
|||
Number of AST nodes: 19 | Number of AST nodes: 19 | |||
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 | gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );↵ | 5 | gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );↵ | |
6 | gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") );↵ | 6 | gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") );↵ | |
7 | s.persist(gavin);↵ | 7 | s.persist(gavin);↵ | |
8 | s.persist(turin);↵ | 8 | s.persist(turin);↵ | |
9 | s.flush();↵ | 9 | s.flush();↵ | |
10 | s.clear();↵ | 10 | s.clear();↵ | |
11 | List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();↵ | 11 | List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();↵ | |
12 | assertEquals( results.size(), 2 );↵ | 12 | assertEquals( results.size(), 2 );↵ | |
13 | gavin = (User) ( (Object[]) results.get(0) )[0];↵ | 13 | gavin = (User) ( (Object[]) results.get(0) )[0];↵ | |
14 | assertEquals( gavin.getName(), "gavin" );↵ | 14 | assertEquals( gavin.getName(), "gavin" );↵ | |
15 | assertEquals( gavin.getSession().size(), 2 );↵ | 15 | assertEquals( gavin.getSession().size(), 2 );↵ | |
16 | s.createQuery("delete SessionAttribute").executeUpdate();↵ | 16 | s.createQuery("delete SessionAttribute").executeUpdate();↵ | |
17 | s.createQuery("delete User").executeUpdate();↵ | 17 | s.createQuery("delete User").executeUpdate();↵ | |
18 | t.commit();↵ | 18 | t.commit();↵ | |
19 | s.close(); | 19 |
| |
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 | 297 |
Number of mapped statements | 16 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
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 | gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz")); |
| 5 | gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz")); | |||||||||||||||
6 | gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2")); |
| 6 | gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2")); | |||||||||||||||
7 | s.persist(gavin); |
| 7 | s.persist(gavin); | |||||||||||||||
8 | s.persist(turin); |
| 8 | s.persist(turin); | |||||||||||||||
9 | s.flush(); | 9 | s.flush(); | ||||||||||||||||
10 | s.clear(); | 10 | s.clear(); | ||||||||||||||||
11 | List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list(); | 11 | List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list(); | ||||||||||||||||
12 | assertEquals(results.size(), 2); | 12 | assertEquals(results.size(), 2); | ||||||||||||||||
|
| 13 | gavin = (User)((Object[])results.get(0))[0]; | ||||||||||||||||
13 | gavin = (User)((Object[])results.get(0))[0]; |
| | ||||||||||||||||
14 | assertEquals(gavin.getName(), "gavin"); |
| 14 | assertEquals(gavin.getName(), "gavin"); | |||||||||||||||
15 | assertEquals(gavin.getSession().size(), 2); |
| 15 | assertEquals(gavin.getSession().size(), 2); | |||||||||||||||
16 | s.createQuery("delete SessionAttribute").executeUpdate(); | 16 | s.createQuery("delete SessionAttribute").executeUpdate(); | ||||||||||||||||
17 | s.createQuery("delete User").executeUpdate(); | 17 | s.createQuery("delete User").executeUpdate(); | ||||||||||||||||
18 | t.commit(); | 18 | t.commit(); | ||||||||||||||||
19 | s.close(); | 19 | s.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.extralazy.SessionAttribute of variable new SessionAttribute("foo","foo bar baz") does not match with type org.hibernate.test.map.SessionAttribute of variable new SessionAttribute("foo","foo bar baz") |
2 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
3 | Type org.hibernate.test.extralazy.SessionAttribute of variable new SessionAttribute("bar","foo bar baz 2") does not match with type org.hibernate.test.map.SessionAttribute of variable new SessionAttribute("bar","foo bar baz 2") |
4 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
5 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
6 | Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.map.User of variable turin |
7 | Unmatched statement gavin=(User)((Object[])results.get(0))[0]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement gavin=(User)((Object[])results.get(0))[0]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |
10 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin |