File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/join/OptionalJoinTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/version/VersionTest.java | |||
Method name: void testUpdateNullOptionalJoinToNonNullDetached()
|
Method name: void testCollectionNoVersion()
|
|||
Number of AST nodes: 30 | Number of AST nodes: 29 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction t = s.beginTransaction();↵ | 2 | Transaction t = s.beginTransaction();↵ | |
3 | // create a new thing with a null name↵ | 3 | ↵ | |
4 | Thing thing = new Thing();↵ | 4 | Person gavin = new ↵ | |
5 | thing.setName(null);↵ | |||
6 | s.save(th↵ | 5 | Person("Gavin");↵ | |
6 | new Task("Code", gavin);↵ | |||
7 | ing);↵ | 7 | s.persist(gavin);↵ | |
8 | t.commit();↵ | 8 | t.commit();↵ | |
9 | s.close();↵ | 9 | s.close();↵ | |
10 | ↵ | |||
11 | assertEquals(0, gavin.getVersion());↵ | |||
12 | ↵ | |||
10 | s = openSession();↵ | 13 | s = openSession();↵ | |
11 | t = s.beginTransaction();↵ | 14 | t = s.beginTransaction();↵ | |
12 | List things = s.createQuery("from Thing").list();↵ | 15 | ↵ | |
13 | assertEquals(1, things.size());↵ | 16 | gavin = (Person) s.createCriteria(Person.class).uniqueResult();↵ | |
14 | thing = (Thing)things.get(0);↵ | 17 | ↵ | |
15 | assertNull(thing.getName());↵ | 18 | new Task("Document", gavin);↵ | |
16 | t.commit();↵ | 19 | t.commit();↵ | |
17 | s.close();↵ | 20 | s.close();↵ | |
21 | ↵ | |||
18 | // change detached thing name to a non-null value↵ | 22 | ↵ | |
19 | thing.setName("two");↵ | |||
20 | s = openSession();↵ | |||
21 | t = s.beginTransaction();↵ | |||
22 | s.update(thing↵ | 23 | assertEquals(0, gavin.getVersion());↵ | |
24 | assertFalse( Hibernate.isInitialized( gavin.getTasks() ) );↵ | |||
25 | s = openSession();↵ | |||
26 | t = s.beginTransaction();↵ | |||
27 | gavin = (Person) s.createCriteria(Person.class).uniqueResult();↵ | |||
23 | );↵ | 28 | gavin.getTasks().clear();↵ | |
24 | t.commit();↵ | 29 | t.commit();↵ | |
25 | s.close();↵ | 30 | s.close();↵ | |
31 | ↵ | |||
26 | s = openSession();↵ | 32 | ↵ | |
27 | t = s.beginTransaction();↵ | 33 | assertEquals(0, gavin.getVersion());↵ | |
28 | things = s.createQuery("from Thing").list();↵ | 34 | ↵ | |
29 | assertEquals(1, things.size());↵ | 35 | assertTrue( Hibernate.isInitialized( gavin.getTasks() ) );↵ | |
30 | thing = ((Thing) things.get(0));↵ | 36 | ↵ | |
31 | assertEquals("two", thing.getName()↵ | 37 | s = openSession();↵ | |
32 | );↵ | 38 | t = s.beginTransaction();↵ | |
33 | s.delete(thing);↵ | 39 | s.delete(gavin);↵ | |
34 | t.commit();↵ | 40 | t.commit();↵ | |
35 | s.close(); | 41 |
| |
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 | 274 |
Number of mapped statements | 20 |
Number of unmapped statements in the first code fragment | 10 |
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 s = openSession(); | ||||||||||||||||||||||
2 | Transaction t = s.beginTransaction(); | 2 | Transaction t = s.beginTransaction(); | ||||||||||||||||||||||
|
| 3 | Person gavin = new Person("Gavin"); | ||||||||||||||||||||||
3 | Thing thing = new Thing(); | | |||||||||||||||||||||||
| 4 | new Task("Code", gavin); | |||||||||||||||||||||||
4 | thing.setName(null); |
| | ||||||||||||||||||||||
|
| 5 | s.persist(gavin); | ||||||||||||||||||||||
5 | s.save(thing); |
| | ||||||||||||||||||||||
6 | t.commit(); | 6 | t.commit(); | ||||||||||||||||||||||
7 | s.close(); | 7 | s.close(); | ||||||||||||||||||||||
8 | s = openSession(); | 9 | s = openSession(); | ||||||||||||||||||||||
9 | t = s.beginTransaction(); | 10 | t = s.beginTransaction(); | ||||||||||||||||||||||
10 | List things = s.createQuery("from Thing").list(); |
| | ||||||||||||||||||||||
|
| 11 | gavin = (Person)s.createCriteria(Person.class).uniqueResult(); | ||||||||||||||||||||||
| 12 | new Task("Document", gavin); | |||||||||||||||||||||||
11 | assertEquals(1, things.size()); |
| 16 | assertFalse(Hibernate.isInitialized(gavin.getTasks())); | |||||||||||||||||||||
12 | thing = (Thing)things.get(0); | | |||||||||||||||||||||||
13 | assertNull(thing.getName()); |
| 8 | assertEquals(0, gavin.getVersion()); | |||||||||||||||||||||
14 | t.commit(); | 13 | t.commit(); | ||||||||||||||||||||||
15 | s.close(); | 14 | s.close(); | ||||||||||||||||||||||
| 15 | assertEquals(0, gavin.getVersion()); | |||||||||||||||||||||||
16 | thing.setName("two"); |
| | ||||||||||||||||||||||
17 | s = openSession(); | 17 | s = openSession(); | ||||||||||||||||||||||
18 | t = s.beginTransaction(); | 18 | t = s.beginTransaction(); | ||||||||||||||||||||||
|
| 19 | gavin = (Person)s.createCriteria(Person.class).uniqueResult(); | ||||||||||||||||||||||
19 | s.update(thing); |
| | ||||||||||||||||||||||
| 20 | gavin.getTasks().clear(); | |||||||||||||||||||||||
20 | t.commit(); | 21 | t.commit(); | ||||||||||||||||||||||
21 | s.close(); | 22 | s.close(); | ||||||||||||||||||||||
| 23 | assertEquals(0, gavin.getVersion()); | |||||||||||||||||||||||
22 | s = openSession(); | 25 | s = openSession(); | ||||||||||||||||||||||
23 | t = s.beginTransaction(); | 26 | t = s.beginTransaction(); | ||||||||||||||||||||||
24 | things = s.createQuery("from Thing").list(); |
| | ||||||||||||||||||||||
25 | assertEquals(1, things.size()); |
| 24 | assertTrue(Hibernate.isInitialized(gavin.getTasks())); | |||||||||||||||||||||
26 | thing = ((Thing)things.get(0)); |
| | ||||||||||||||||||||||
27 | assertEquals("two", thing.getName()); | | |||||||||||||||||||||||
28 | s.delete(thing); |
| 27 | s.delete(gavin); | |||||||||||||||||||||
29 | t.commit(); | 28 | t.commit(); | ||||||||||||||||||||||
30 | s.close(); | 29 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement Person gavin=new Person("Gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement thing.setName(null); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement s.persist(gavin); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement s.save(thing); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement List things=s.createQuery("from Thing").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement gavin=(Person)s.createCriteria(Person.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Expression assertEquals(1,things.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression assertFalse(Hibernate.isInitialized(gavin.getTasks())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
10 | Expression assertFalse(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
11 | Expression assertEquals(1,things.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression assertFalse(Hibernate.isInitialized(gavin.getTasks())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
14 | Expression assertFalse(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
15 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression assertEquals(0,gavin.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
18 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
19 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression assertEquals(0,gavin.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
22 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
23 | Unmatched statement thing.setName("two"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | Unmatched statement gavin=(Person)s.createCriteria(Person.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Unmatched statement s.update(thing); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Unmatched statement things=s.createQuery("from Thing").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
27 | Expression assertEquals(1,things.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
30 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
31 | Expression assertEquals(1,things.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
32 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
33 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
34 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
35 | Unmatched statement thing=((Thing)things.get(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
36 | Type org.hibernate.test.join.Thing of variable thing does not match with type org.hibernate.test.version.Person of variable gavin |