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 | 338 |
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 8 |
Number of unmapped statements in the second code fragment | 9 |
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 | p.setEmployeeId("123456"); | ||||||||||||||||||||||||
4 | s.persist(p); |
| 5 | session.persist(p); | ||||||||||||||||||||||
5 | t.commit(); |
| 6 | tx.commit(); | ||||||||||||||||||||||
|
| 8 | session = openSession(); | |||||||||||||||||||||||
6 | s.clear(); |
| 20 | session.delete(p); | ||||||||||||||||||||||
7 | t = s.beginTransaction(); |
| 9 | tx = session.beginTransaction(); | ||||||||||||||||||||||
8 | p = (Point)s.createCriteria(Point.class).uniqueResult(); |
| | |||||||||||||||||||||||
9 | p.setDescription("new desc"); | | ||||||||||||||||||||||||
|
| 10 | p = (Person)session.get(Person.class, "gavin"); | |||||||||||||||||||||||
10 | t.commit(); |
| 13 | tx.commit(); | ||||||||||||||||||||||
11 | s.clear(); |
| 11 | assertNull(p.getEmployee()); | ||||||||||||||||||||||
|
| 12 | p.setEmployee(new Employee("123456")); | |||||||||||||||||||||||
12 | t = s.beginTransaction(); |
| 16 | tx = session.beginTransaction(); | ||||||||||||||||||||||
13 | p = (Point)s.createQuery("from Point").uniqueResult(); | | ||||||||||||||||||||||||
| 14 | session.close(); | ||||||||||||||||||||||||
14 | p.setDescription("new new desc"); | | ||||||||||||||||||||||||
|
| 15 | session = openSession(); | |||||||||||||||||||||||
|
| 17 | p = (Person)session.get(Person.class, "gavin"); | |||||||||||||||||||||||
15 | t.commit(); |
| 21 | tx.commit(); | ||||||||||||||||||||||
16 | s.clear(); |
| 18 | assertTrue(Hibernate.isInitialized(p.getEmployee())); | ||||||||||||||||||||||
17 | t = s.beginTransaction(); |
| | |||||||||||||||||||||||
18 | p = (Point)s.get(Point.class, p); | | ||||||||||||||||||||||||
19 | p.setDescription("new new new desc"); | | ||||||||||||||||||||||||
20 | t.commit(); |
| 19 | assertNotNull(p.getEmployee()); | ||||||||||||||||||||||
21 | s.close(); |
| 7 | session.close(); | ||||||||||||||||||||||
| 22 | session.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p |
2 | Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
5 | Expression session.delete(p) is a void method call, and thus it cannot be parameterized |
6 | Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
8 | Expression session.delete(p) is a void method call, and thus it cannot be parameterized |
9 | 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 |
10 | 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 |
11 | Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
13 | Expression assertNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized |
14 | Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
16 | Expression assertNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized |
17 | Unmatched statement p.setEmployee(new Employee("123456")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | 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 |
20 | Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
22 | Expression assertTrue(Hibernate.isInitialized(p.getEmployee())) is a void method call, and thus it cannot be parameterized |
23 | Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression s.clear() is a void method call, and thus it cannot be parameterized |
25 | Expression assertTrue(Hibernate.isInitialized(p.getEmployee())) is a void method call, and thus it cannot be parameterized |
26 | 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 |
27 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
29 | Expression assertNotNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized |
30 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
31 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
32 | Expression assertNotNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized |