File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java | |||
Method name: void testStatefulIntercept()
|
Method name: void testFindBySQLDiscriminatedDiffSession()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 16 | |||
1 | final StatefulInterceptor statefulInterceptor = new StatefulInterceptor();↵ | |||
2 | Session s = openSession( statefulInterceptor );↵ | 1 | Session session = openSession(↵ | |
3 | statefulInterceptor.setSession(s);↵ | |||
4 | Transaction t = s.beginTransaction↵ | 2 | );↵ | |
3 | session.delete("from A");↵ | |||
4 | A savedA = new A();↵ | |||
5 | session.save(savedA);↵ | |||
5 | ();↵ | 6 | B savedB = new B();↵ | |
6 | User u = new User("Gavin", "nivag");↵ | 7 | se↵ | |
7 | s.persist(u↵ | 8 | ssion.save(savedB);↵ | |
8 | );↵ | 9 | session.flush();↵ | |
9 | u.setPassword("vagni");↵ | 10 | ↵ | |
10 | t.commit();↵ | 11 | int count = session.createQuery("from A").list().size();↵ | |
11 | s.close();↵ | 12 | session.close();↵ | |
12 | s = openSession();↵ | 13 | session = openSession();↵ | |
13 | t = s.beginTransaction();↵ | 14 | ↵ | |
14 | List logs = s.createCriteria(Log.class).↵ | 15 | Query query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA", "a", A.class);↵ | |
16 | List list = query.list();↵ | |||
15 | list();↵ | 17 | assertNotNull(list);↵ | |
16 | assertEquals( 2, logs.size() );↵ | 18 | assertEquals(count, list.size());↵ | |
17 | s.delete(u);↵ | 19 | s↵ | |
18 | s.createQuery( "delete from Log" ).executeUpdate();↵ | |||
19 | t.commit();↵ | 20 | ession.connection().commit();↵ | |
20 | s.close(); | 21 | session.close(); | |
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 | 272 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 12 |
Number of unmapped statements in the second code fragment | 11 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Session session = openSession(); | ||||||||||||||||||||||||
1 | final StatefulInterceptor statefulInterceptor = new StatefulInterceptor(); | | ||||||||||||||||||||||||
| 2 | session.delete("from A"); | ||||||||||||||||||||||||
2 | Session s = openSession(statefulInterceptor); | | ||||||||||||||||||||||||
| 3 | A savedA = new A(); | ||||||||||||||||||||||||
3 | statefulInterceptor.setSession(s); | | ||||||||||||||||||||||||
| 4 | session.save(savedA); | ||||||||||||||||||||||||
4 | Transaction t = s.beginTransaction(); | | ||||||||||||||||||||||||
| 5 | B savedB = new B(); | ||||||||||||||||||||||||
5 | User u = new User("Gavin", "nivag"); | | ||||||||||||||||||||||||
| 6 | session.save(savedB); | ||||||||||||||||||||||||
6 | s.persist(u); | | ||||||||||||||||||||||||
7 | u.setPassword("vagni"); | | ||||||||||||||||||||||||
| 8 | int count = session.createQuery("from A").list().size(); | ||||||||||||||||||||||||
8 | t.commit(); |
| 13 | assertNotNull(list); | ||||||||||||||||||||||
9 | s.close(); |
| 9 | session.close(); | ||||||||||||||||||||||
10 | s = openSession(); |
| | |||||||||||||||||||||||
11 | t = s.beginTransaction(); |
| | |||||||||||||||||||||||
12 | List logs = s.createCriteria(Log.class).list(); | | ||||||||||||||||||||||||
13 | assertEquals(2, logs.size()); |
| 7 | session.flush(); | ||||||||||||||||||||||
|
| 10 | session = openSession(); | |||||||||||||||||||||||
| 11 | Query query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA", "a", A.class); | ||||||||||||||||||||||||
| 12 | List list = query.list(); | ||||||||||||||||||||||||
14 | s.delete(u); | | ||||||||||||||||||||||||
15 | s.createQuery("delete from Log").executeUpdate(); | | ||||||||||||||||||||||||
16 | t.commit(); |
| 14 | assertEquals(count, list.size()); | ||||||||||||||||||||||
| 15 | session.connection().commit(); | ||||||||||||||||||||||||
17 | s.close(); |
| 16 | session.close(); |
Row | Violation |
---|---|
1 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
2 | Expression assertNotNull(list) is a void method call, and thus it cannot be parameterized |
3 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
4 | Expression assertNotNull(list) is a void method call, and thus it cannot be parameterized |
5 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable session |
6 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression assertEquals(2,logs.size()) is a void method call, and thus it cannot be parameterized |
9 | Expression session.flush() is a void method call, and thus it cannot be parameterized |
10 | Expression assertEquals(2,logs.size()) is a void method call, and thus it cannot be parameterized |
11 | Expression session.flush() is a void method call, and thus it cannot be parameterized |
12 | Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
15 | Expression assertEquals(count,list.size()) is a void method call, and thus it cannot be parameterized |
16 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
18 | Expression assertEquals(count,list.size()) is a void method call, and thus it cannot be parameterized |
19 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable session |