File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java | |||
Method name: void testRefresh()
|
Method name: void testUnionSubclassCollection()
|
|||
Number of AST nodes: 22 | Number of AST nodes: 21 | |||
1 | StatelessSession ss = getSessions().openStatelessSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction tx = ss.beginTransaction();↵ | 2 | Transaction t = s.beginTransaction();↵ | |
3 | Paper paper = new Paper();↵ | 3 | ↵ | |
4 | paper.setColor( "whtie" );↵ | |||
5 | ss.insert( paper );↵ | |||
6 | tx.commit();↵ | |||
7 | ss.close(↵ | 4 | Location mel = new Location("Earth");↵ | |
5 | s.save(mel);↵ | |||
6 | ↵ | |||
7 | Human gavin = new Human();↵ | |||
8 | gavin.setIdentity("gavin");↵ | |||
8 | );↵ | 9 | gavin.setSex('M');↵ | |
9 | ss = getSessions().openStatelessSession();↵ | 10 | gavin.setLocation(mel);↵ | |
10 | tx = ss.beginTransaction();↵ | 11 | ↵ | |
11 | Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() );↵ | |||
12 | p2.setColor( "White" );↵ | |||
13 | ss.update( p2 ↵ | 12 | mel.addBeing(gavin);↵ | |
13 | ↵ | |||
14 | gavin.getInfo().put("foo", "bar");↵ | |||
14 | );↵ | 15 | gavin.getInfo().put("x", "y");↵ | |
15 | ↵ | 16 | ↵ | |
16 | tx.commit();↵ | 17 | t.commit();↵ | |
17 | ss.close();↵ | 18 | s.close();↵ | |
18 | ss = getSessions().openStatelessSession();↵ | 19 | s = openSession();↵ | |
19 | tx = ss.beginTransaction();↵ | 20 | t = s.beginTransaction();↵ | |
20 | assertEquals( "whtie", paper.getColor() );↵ | 21 | ↵ | |
21 | ss.refresh( paper );↵ | 22 | gavin = (Human) s.createCriteria(Human.class).uniqueResult();↵ | |
22 | assertEquals( "White", paper.getColor() );↵ | 23 | assertEquals( ↵ | |
23 | ss.delete( paper↵ | 24 | gavin.getInfo().size(), 2 );↵ | |
25 | s.delete(gavin);↵ | |||
24 | );↵ | 26 | s.delete( gavin.getLocation() );↵ | |
25 | tx.commit();↵ | 27 | t.commit();↵ | |
26 | ss.close(); | 28 | s.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 | 433 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 14 |
Number of unmapped statements in the second code fragment | 13 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Session s = openSession(); | |||||||||||||||||||||||
1 | StatelessSession ss = getSessions().openStatelessSession(); | | |||||||||||||||||||||||
2 | Transaction tx = ss.beginTransaction(); |
| 2 | Transaction t = s.beginTransaction(); | |||||||||||||||||||||
| 3 | Location mel = new Location("Earth"); | |||||||||||||||||||||||
3 | Paper paper = new Paper(); | | |||||||||||||||||||||||
| 4 | s.save(mel); | |||||||||||||||||||||||
4 | paper.setColor("whtie"); | | |||||||||||||||||||||||
| 5 | Human gavin = new Human(); | |||||||||||||||||||||||
5 | ss.insert(paper); | | |||||||||||||||||||||||
6 | tx.commit(); |
| | ||||||||||||||||||||||
7 | ss.close(); | | |||||||||||||||||||||||
| 8 | gavin.setLocation(mel); | |||||||||||||||||||||||
8 | ss = getSessions().openStatelessSession(); |
| | ||||||||||||||||||||||
9 | tx = ss.beginTransaction(); |
| | ||||||||||||||||||||||
10 | Paper p2 = (Paper)ss.get(Paper.class, paper.getId()); | | |||||||||||||||||||||||
11 | p2.setColor("White"); | | |||||||||||||||||||||||
12 | ss.update(p2); | | |||||||||||||||||||||||
13 | tx.commit(); |
| 12 | t.commit(); | |||||||||||||||||||||
14 | ss.close(); | | |||||||||||||||||||||||
15 | ss = getSessions().openStatelessSession(); | | |||||||||||||||||||||||
16 | tx = ss.beginTransaction(); |
| 15 | t = s.beginTransaction(); | |||||||||||||||||||||
17 | assertEquals("whtie", paper.getColor()); |
| 7 | gavin.setSex('M'); | |||||||||||||||||||||
18 | ss.refresh(paper); |
| 17 | assertEquals(gavin.getInfo().size(), 2); | |||||||||||||||||||||
19 | assertEquals("White", paper.getColor()); |
| 6 | gavin.setIdentity("gavin"); | |||||||||||||||||||||
| 9 | mel.addBeing(gavin); | |||||||||||||||||||||||
| 10 | gavin.getInfo().put("foo", "bar"); | |||||||||||||||||||||||
| 11 | gavin.getInfo().put("x", "y"); | |||||||||||||||||||||||
| 13 | s.close(); | |||||||||||||||||||||||
|
| 14 | s = openSession(); | ||||||||||||||||||||||
|
| 16 | gavin = (Human)s.createCriteria(Human.class).uniqueResult(); | ||||||||||||||||||||||
20 | ss.delete(paper); |
| 18 | s.delete(gavin); | |||||||||||||||||||||
| 19 | s.delete(gavin.getLocation()); | |||||||||||||||||||||||
21 | tx.commit(); |
| 20 | t.commit(); | |||||||||||||||||||||
| 21 | s.close(); | |||||||||||||||||||||||
22 | ss.close(); | |
Row | Violation |
---|---|
1 | Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s |
2 | Unmatched statement tx.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement ss=getSessions().openStatelessSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s |
6 | Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized |
7 | Expression gavin.setSex('M') is a void method call, and thus it cannot be parameterized |
8 | Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized |
9 | Expression gavin.setSex('M') is a void method call, and thus it cannot be parameterized |
10 | Expression ss.refresh(paper) is a void method call, and thus it cannot be parameterized |
11 | Expression assertEquals(gavin.getInfo().size(),2) is a void method call, and thus it cannot be parameterized |
12 | Expression ss.refresh(paper) is a void method call, and thus it cannot be parameterized |
13 | Expression assertEquals(gavin.getInfo().size(),2) is a void method call, and thus it cannot be parameterized |
14 | Expression assertEquals("White",paper.getColor()) is a void method call, and thus it cannot be parameterized |
15 | Expression gavin.setIdentity("gavin") is a void method call, and thus it cannot be parameterized |
16 | Expression assertEquals("White",paper.getColor()) is a void method call, and thus it cannot be parameterized |
17 | Expression gavin.setIdentity("gavin") is a void method call, and thus it cannot be parameterized |
18 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement gavin=(Human)s.createCriteria(Human.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Type org.hibernate.test.stateless.Paper of variable paper does not match with type org.hibernate.test.unionsubclass.Human of variable gavin |
21 | Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s |
22 | Clone fragment #1 returns variables tx , while Clone fragment #2 returns variables |