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 testUpdateNonNullOptionalJoinToNullDetached()
|
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 non-null name↵ | 3 | ↵ | |
4 | Thing thing = new Thing();↵ | |||
5 | thing.setName("one");↵ | |||
6 | s.save(th↵ | 4 | Person gavin = new Person("Gavin");↵ | |
5 | new Task("Code", gavin);↵ | |||
7 | ing);↵ | 6 | s.persist(gavin);↵ | |
8 | t.commit();↵ | 7 | t.commit();↵ | |
9 | s.close();↵ | 8 | s.close();↵ | |
9 | ↵ | |||
10 | assertEquals(0, gavin.getVersion());↵ | |||
11 | ↵ | |||
10 | s = openSession();↵ | 12 | s = openSession();↵ | |
11 | t = s.beginTransaction();↵ | 13 | t = s.beginTransaction();↵ | |
12 | List things = s.createQuery("from Thing").list();↵ | 14 | ↵ | |
13 | assertEquals(1, things.size());↵ | |||
14 | thing = (Thing)things.get(0↵ | 15 | gavin = (Person) s.createCriteria(Person.class).uniqueResult();↵ | |
16 | new Task("Document", gavin);↵ | |||
17 | t.commit();↵ | |||
15 | );↵ | 18 | s.close();↵ | |
16 | ↵ | 19 | ↵ | |
17 | assertEquals("one", thing.getName());↵ | 20 | assertEquals(0, gavin.get↵ | |
18 | t.commit();↵ | |||
19 | s.close();↵ | |||
20 | // give detached thing a null name and save it↵ | |||
21 | thing.setName(null);↵ | |||
22 | s = openSession();↵ | |||
23 | t = s.beginTransaction();↵ | |||
24 | s.update(thing↵ | 21 | Version());↵ | |
22 | assertFalse( Hibernate.isInitialized( gavin.getTasks() ) );↵ | |||
23 | s = openSession();↵ | |||
24 | t = s.beginTransaction();↵ | |||
25 | gavin = (Person) s.createCriteria(Person.class).uniqueResult();↵ | |||
25 | );↵ | 26 | gavin.getTasks().clear();↵ | |
26 | t.commit();↵ | 27 | t.commit();↵ | |
27 | s.close();↵ | 28 | s.close();↵ | |
29 | ↵ | |||
28 | s = openSession();↵ | 30 | ↵ | |
29 | t = s.beginTransaction();↵ | 31 | assertEquals(0, gavin.getVersion());↵ | |
30 | things = s.createQuery("from Thing").list();↵ | 32 | ↵ | |
31 | assertEquals(1, things.size());↵ | 33 | assertTrue( Hibernate.isInitialized( gavin.getTasks() ) );↵ | |
32 | thing = (Thing)things.get(0);↵ | 34 | ↵ | |
33 | assertNull(thing.getName()↵ | 35 | s = openSession();↵ | |
34 | );↵ | 36 | t = s.beginTransaction();↵ | |
35 | s.delete(thing);↵ | 37 | s.delete(gavin);↵ | |
36 | t.commit();↵ | 38 | t.commit();↵ | |
37 | s.close(); | 39 |
| |
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("one"); |
| | ||||||||||||||||||||||
|
| 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(); | ||||||||||||||||||||||
11 | assertEquals(1, things.size()); | | |||||||||||||||||||||||
| 12 | new Task("Document", gavin); | |||||||||||||||||||||||
12 | thing = (Thing)things.get(0); | | |||||||||||||||||||||||
13 | assertEquals("one", thing.getName()); |
| 16 | assertFalse(Hibernate.isInitialized(gavin.getTasks())); | |||||||||||||||||||||
14 | t.commit(); | 13 | t.commit(); | ||||||||||||||||||||||
15 | s.close(); | 14 | s.close(); | ||||||||||||||||||||||
| 15 | assertEquals(0, gavin.getVersion()); | |||||||||||||||||||||||
16 | thing.setName(null); |
| | ||||||||||||||||||||||
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 | assertNull(thing.getName()); |
| 8 | assertEquals(0, gavin.getVersion()); | |||||||||||||||||||||
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("one"); 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("one",thing.getName()) 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("one",thing.getName()) 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("one",thing.getName()) 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("one",thing.getName()) 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 | Unmatched statement thing.setName(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | 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 |
17 | 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 |
18 | 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 |
19 | Expression assertEquals(1,things.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
22 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
23 | Expression assertEquals(1,things.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
26 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
27 | 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 |
28 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression assertEquals(0,gavin.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
31 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
32 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
33 | Expression assertEquals(0,gavin.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
34 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
35 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
36 | Type org.hibernate.test.join.Thing of variable thing does not match with type org.hibernate.test.version.Person of variable gavin |