File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/rowid/RowIdTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/unconstrained/UnconstrainedTest.java | |||
Method name: void testRowId()
|
Method name: void testUnconstrained()
|
|||
Number of AST nodes: 21 | Number of AST nodes: 22 | |||
1 | Session s = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | Transaction t = s.beginTransaction();↵ | 2 | Transaction tx = session.beginTransaction();↵ | |
3 | Point p = new Point( new BigDecimal(1.0), new BigDecimal(1.0) );↵ | 3 | Person p = new P↵ | |
4 | s↵ | 4 | erson("gavin");↵ | |
5 | p.setEmployeeId("123456");↵ | |||
5 | .persist(p);↵ | 6 | session.persist(p);↵ | |
6 | t.commit();↵ | 7 | tx.commit();↵ | |
7 | s.clear();↵ | 8 | s↵ | |
8 | ↵ | |||
9 | t = s.beginTransaction();↵ | |||
10 | p = (Point) s.createCriteria(Point.class).uniqueResult();↵ | |||
11 | p.setDescription("new desc"↵ | 9 | ession.close();↵ | |
10 | ↵ | |||
11 | session = openSession();↵ | |||
12 | tx = session.beginTransaction();↵ | |||
13 | p = (Person) session.get(Person.class, "gavin");↵ | |||
14 | assertNull( p.getEmployee() );↵ | |||
12 | );↵ | 15 | p.setEmployee( new Employee("123456") );↵ | |
13 | t.commit();↵ | 16 | tx.commit();↵ | |
14 | s.clear();↵ | 17 | session.close();↵ | |
15 | ↵ | 18 | session = openSession();↵ | |
16 | t = s.beginTransaction();↵ | 19 | tx = session.beginTransaction();↵ | |
17 | p = (Point) s.createQuery("from Point").uniqueResult();↵ | 20 | p = (Person) session.get(Person.class, "gavin")↵ | |
18 | p.setDescription("new new desc");↵ | |||
19 | t.commit();↵ | |||
20 | s.clear();↵ | |||
21 | ↵ | |||
22 | t = s.beginTransaction();↵ | |||
23 | p = (Point) s.get(Point.class, p);↵ | |||
24 | p.setDescription("new new new desc"↵ | 21 | ;↵ | |
22 | assertTrue( Hibernate.isInitialized( p.getEmployee() ) );↵ | |||
23 | assertNotNull( p.getEmployee() );↵ | |||
25 | );↵ | 24 | session.delete(p);↵ | |
26 | t.commit();↵ | 25 | tx.commit();↵ | |
27 | s.close(); | 26 | 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 | 311 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 13 |
Number of unmapped statements in the second code fragment | 14 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); |
| 1 | Session session = openSession(); | |||||||||||||||||||||
2 | Transaction t = s.beginTransaction(); |
| 2 | Transaction tx = session.beginTransaction(); | |||||||||||||||||||||
|
| 3 | Person p = new Person("gavin"); | ||||||||||||||||||||||
3 | Point p = new Point(new BigDecimal(1.0), new BigDecimal(1.0)); |
| | ||||||||||||||||||||||
4 | s.persist(p); |
| 5 | session.persist(p); | |||||||||||||||||||||
5 | t.commit(); |
| 6 | tx.commit(); | |||||||||||||||||||||
6 | s.clear(); |
| | ||||||||||||||||||||||
7 | t = s.beginTransaction(); |
| | ||||||||||||||||||||||
8 | p = (Point)s.createCriteria(Point.class).uniqueResult(); |
| | ||||||||||||||||||||||
9 | p.setDescription("new desc"); |
| 4 | p.setEmployeeId("123456"); | |||||||||||||||||||||
|
| 8 | session = openSession(); | ||||||||||||||||||||||
|
| 9 | tx = session.beginTransaction(); | ||||||||||||||||||||||
|
| 10 | p = (Person)session.get(Person.class, "gavin"); | ||||||||||||||||||||||
| 11 | assertNull(p.getEmployee()); | |||||||||||||||||||||||
|
| 12 | p.setEmployee(new Employee("123456")); | ||||||||||||||||||||||
10 | t.commit(); |
| 13 | tx.commit(); | |||||||||||||||||||||
11 | s.clear(); |
| | ||||||||||||||||||||||
12 | t = s.beginTransaction(); |
| | ||||||||||||||||||||||
13 | p = (Point)s.createQuery("from Point").uniqueResult(); |
| | ||||||||||||||||||||||
| 14 | session.close(); | |||||||||||||||||||||||
14 | p.setDescription("new new desc"); |
| | ||||||||||||||||||||||
|
| 15 | session = openSession(); | ||||||||||||||||||||||
|
| 16 | tx = session.beginTransaction(); | ||||||||||||||||||||||
| 17 | p = (Person)session.get(Person.class, "gavin"); | |||||||||||||||||||||||
| 18 | assertTrue(Hibernate.isInitialized(p.getEmployee())); | |||||||||||||||||||||||
| 19 | assertNotNull(p.getEmployee()); | |||||||||||||||||||||||
| 20 | session.delete(p); | |||||||||||||||||||||||
15 | t.commit(); |
| 21 | tx.commit(); | |||||||||||||||||||||
16 | s.clear(); |
| | ||||||||||||||||||||||
17 | t = s.beginTransaction(); |
| | ||||||||||||||||||||||
18 | p = (Point)s.get(Point.class, p); |
| | ||||||||||||||||||||||
19 | p.setDescription("new new new desc"); |
| | ||||||||||||||||||||||
20 | t.commit(); |
| | ||||||||||||||||||||||
21 | s.close(); |
| 7 | session.close(); | |||||||||||||||||||||
| 22 | session.close(); |
Row | Violation |
---|---|
1 | Unmatched statement Person p=new Person("gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement Point p=new Point(new BigDecimal(1.0),new BigDecimal(1.0)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p |
4 | Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | 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 |
6 | Unmatched statement p=(Point)s.createCriteria(Point.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Expression p.setDescription("new desc") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression p.setEmployeeId("123456") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression p.setDescription("new desc") is a void method call, and thus it cannot be parameterized |
10 | Expression p.setEmployeeId("123456") is a void method call, and thus it cannot be parameterized |
11 | Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p |
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 | Unmatched statement tx=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement p=(Person)session.get(Person.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Unmatched statement p.setEmployee(new Employee("123456")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
16 | Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | 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 |
18 | Unmatched statement p=(Point)s.createQuery("from Point").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement p.setDescription("new new desc"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Unmatched statement session=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
21 | Unmatched statement tx=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | 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 |
24 | Unmatched statement p=(Point)s.get(Point.class,p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Unmatched statement p.setDescription("new new new desc"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
26 | Unmatched statement t.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
27 | Clone fragment #1 returns variables s, t , while Clone fragment #2 returns variables session, tx |