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/FooBarTest.java | |||
Method name: void testStatefulIntercept()
|
Method name: void testSerializableType()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 17 | |||
1 | final StatefulInterceptor statefulInterceptor = new StatefulInterceptor();↵ | |||
2 | Session s = openSession( statefulInterceptor );↵ | |||
3 | statefulInterceptor.setSession(s);↵ | |||
4 | Transaction t = s.beginTransaction();↵ | |||
5 | User u = new User("Gavin", "nivag");↵ | |||
6 | s.persist(u);↵ | |||
7 | u.setPassword("vagni");↵ | |||
8 | t↵ | 1 | Session s = openSession();↵ | |
2 | Vetoer v = new Vetoer();↵ | |||
3 | v.setStrings( new String[] { "foo", "bar", "baz" } );↵ | |||
4 | s.save(v); Serializable id = s.save(v);↵ | |||
5 | v.getStrings()[1] = "osama";↵ | |||
6 | s.flush();↵ | |||
9 | .commit();↵ | 7 | s.connection().commit();↵ | |
10 | s.close();↵ | 8 | s.close();↵ | |
11 | s = openSession();↵ | 9 | s = openSession();↵ | |
12 | t = s.beginTransaction();↵ | 10 | v = ↵ | |
13 | List logs = s.createCriteria(Log.class).list();↵ | |||
14 | assertEquals( 2, logs.size(↵ | 11 | (Vetoer) s.load(Vetoer.class, id);↵ | |
15 | ) );↵ | 12 | assertTrue( "serializable type", v.getStrings()[1].equals("osama") );↵ | |
16 | s.delete(u);↵ | 13 | s.delete(v);↵ | |
17 | s.createQuery( "delete from Log" ).executeUpdate();↵ | |||
18 | t↵ | 14 | s.delete(v);↵ | |
15 | s.flush();↵ | |||
19 | .commit();↵ | 16 | s.connection().commit();↵ | |
20 | s.close(); | 17 |
| |
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 | 229 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 12 |
Number of unmapped statements in the second code fragment | 12 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Session s = openSession(); | ||||||||||||||||||||||
1 | final StatefulInterceptor statefulInterceptor = new StatefulInterceptor(); | | ||||||||||||||||||||||
| 2 | Vetoer v = new Vetoer(); | ||||||||||||||||||||||
2 | Session s = openSession(statefulInterceptor); | | ||||||||||||||||||||||
| 3 | v.setStrings(new String[] {"foo", "bar", "baz"}); | ||||||||||||||||||||||
| 4 | s.save(v); | ||||||||||||||||||||||
3 | statefulInterceptor.setSession(s); |
| 12 | assertTrue("serializable type", v.getStrings()[1].equals("osama")); | ||||||||||||||||||||
4 | Transaction t = s.beginTransaction(); | | ||||||||||||||||||||||
| 5 | Serializable id = s.save(v); | ||||||||||||||||||||||
5 | User u = new User("Gavin", "nivag"); | | ||||||||||||||||||||||
| 6 | v.getStrings()[1] = "osama"; | ||||||||||||||||||||||
6 | s.persist(u); | | ||||||||||||||||||||||
| 7 | s.flush(); | ||||||||||||||||||||||
7 | u.setPassword("vagni"); | | ||||||||||||||||||||||
| 8 | s.connection().commit(); | ||||||||||||||||||||||
8 | t.commit(); | | ||||||||||||||||||||||
9 | s.close(); |
| 9 | s.close(); | ||||||||||||||||||||
|
| 10 | s = openSession(); | |||||||||||||||||||||
10 | s = openSession(); |
| | |||||||||||||||||||||
| 11 | v = (Vetoer)s.load(Vetoer.class, id); | ||||||||||||||||||||||
11 | t = s.beginTransaction(); | | ||||||||||||||||||||||
12 | List logs = s.createCriteria(Log.class).list(); | | ||||||||||||||||||||||
13 | assertEquals(2, logs.size()); |
| 13 | s.delete(v); | ||||||||||||||||||||
14 | s.delete(u); |
| 14 | s.delete(v); | ||||||||||||||||||||
| 15 | s.flush(); | ||||||||||||||||||||||
15 | s.createQuery("delete from Log").executeUpdate(); | | ||||||||||||||||||||||
| 16 | s.connection().commit(); | ||||||||||||||||||||||
16 | t.commit(); | | ||||||||||||||||||||||
17 | s.close(); |
| 17 | s.close(); |
Row | Violation |
---|---|
1 | Expression statefulInterceptor.setSession(s) is a void method call, and thus it cannot be parameterized |
2 | Expression assertTrue("serializable type",v.getStrings()[1].equals("osama")) is a void method call, and thus it cannot be parameterized |
3 | Expression statefulInterceptor.setSession(s) is a void method call, and thus it cannot be parameterized |
4 | Expression assertTrue("serializable type",v.getStrings()[1].equals("osama")) 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 s |
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 s=openSession(); 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 s.delete(v) 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 s.delete(v) is a void method call, and thus it cannot be parameterized |
12 | Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.legacy.Vetoer of variable v |
13 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
14 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |