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 | 24 |
Number of unmapped statements in the first code fragment | 6 |
Number of unmapped statements in the second code fragment | 5 |
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); |
| 16 | assertFalse(Hibernate.isInitialized(gavin.getTasks())); | ||||||||||||||||||||||
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 | assertEquals(1, things.size()); |
| 5 | s.persist(gavin); | ||||||||||||||||||||||
12 | thing = (Thing)things.get(0); |
| | |||||||||||||||||||||||
13 | assertNull(thing.getName()); |
| 8 | assertEquals(0, gavin.getVersion()); | ||||||||||||||||||||||
|
| 11 | gavin = (Person)s.createCriteria(Person.class).uniqueResult(); | |||||||||||||||||||||||
| 12 | new Task("Document", gavin); | ||||||||||||||||||||||||
14 | t.commit(); | 13 | t.commit(); | |||||||||||||||||||||||
15 | s.close(); | 14 | s.close(); | |||||||||||||||||||||||
16 | thing.setName("two"); |
| 15 | assertEquals(0, gavin.getVersion()); | ||||||||||||||||||||||
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); |
| 23 | assertEquals(0, gavin.getVersion()); | ||||||||||||||||||||||
20 | t.commit(); | 21 | t.commit(); | |||||||||||||||||||||||
21 | s.close(); | 22 | s.close(); | |||||||||||||||||||||||
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()); |
| 20 | gavin.getTasks().clear(); | ||||||||||||||||||||||
28 | s.delete(thing); |
| 27 | s.delete(gavin); | ||||||||||||||||||||||
29 | t.commit(); | 28 | t.commit(); | |||||||||||||||||||||||
30 | s.close(); | 29 | s.close(); |
Row | Violation |
---|---|
1 | Expression thing.setName(null) is a void method call, and thus it cannot be parameterized |
2 | Expression assertFalse(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
3 | Expression thing.setName(null) is a void method call, and thus it cannot be parameterized |
4 | Expression assertFalse(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
5 | 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 |
6 | 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 |
7 | Expression s.persist(gavin) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
9 | Expression s.persist(gavin) is a void method call, and thus it cannot be parameterized |
10 | Expression s.persist(gavin) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
12 | Expression s.persist(gavin) is a void method call, and thus it cannot be parameterized |
13 | 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 |
14 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
16 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
17 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
19 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
20 | 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 |
21 | Expression thing.setName("two") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression thing.setName("two") is a void method call, and thus it cannot be parameterized |
23 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
24 | Expression thing.setName("two") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression thing.setName("two") is a void method call, and thus it cannot be parameterized |
26 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
27 | 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 |
28 | Expression s.update(thing) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression s.update(thing) is a void method call, and thus it cannot be parameterized |
30 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
31 | Expression s.update(thing) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
32 | Expression s.update(thing) is a void method call, and thus it cannot be parameterized |
33 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
34 | 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 |
35 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
36 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
37 | Expression assertEquals(1,things.size()) is a void method call, and thus it cannot be parameterized |
38 | Expression assertTrue(Hibernate.isInitialized(gavin.getTasks())) is a void method call, and thus it cannot be parameterized |
39 | 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 |
40 | Expression assertEquals("two",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
41 | Expression assertEquals("two",thing.getName()) is a void method call, and thus it cannot be parameterized |
42 | Expression gavin.getTasks().clear() is a void method call, and thus it cannot be parameterized |
43 | Expression assertEquals("two",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
44 | Expression assertEquals("two",thing.getName()) is a void method call, and thus it cannot be parameterized |
45 | Expression gavin.getTasks().clear() is a void method call, and thus it cannot be parameterized |
46 | Type org.hibernate.test.join.Thing of variable thing does not match with type org.hibernate.test.version.Person of variable gavin |