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 testCollectionVersion()
|
|||
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();↵ | 4 | Person gavin = new ↵ | |
5 | thing.setName("one");↵ | |||
6 | s.save(th↵ | 5 | Person("Gavin");↵ | |
6 | new Thing("Passport", 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());↵ | |||
14 | thing = (Thing)things.get(0);↵ | 16 | gavin = (Person) s.createCriteria(Person.class).uniqueResult();↵ | |
17 | new Thing("Laptop", gavin);↵ | |||
18 | t.commit();↵ | |||
19 | s.close();↵ | |||
20 | ↵ | |||
15 | assertEquals("one", thing.getName());↵ | 21 | assertEquals(1, gavin.get↵ | |
16 | t.commit();↵ | |||
17 | s.close();↵ | |||
18 | // give detached thing a null name and save it↵ | |||
19 | thing.setName(null);↵ | |||
20 | s = openSession();↵ | |||
21 | t = s.beginTransaction();↵ | |||
22 | s.update(thing↵ | 22 | Version());↵ | |
23 | assertFalse( Hibernate.isInitialized( gavin.getThings() ) );↵ | |||
24 | s = openSession();↵ | |||
25 | t = s.beginTransaction();↵ | |||
26 | gavin = (Person) s.createCriteria(Person.class).uniqueResult();↵ | |||
23 | );↵ | 27 | gavin.getThings().clear();↵ | |
24 | t.commit();↵ | 28 | t.commit();↵ | |
25 | s.close();↵ | 29 | s.close();↵ | |
30 | ↵ | |||
26 | s = openSession();↵ | 31 | ↵ | |
27 | t = s.beginTransaction();↵ | 32 | assertEquals(2, gavin.getVersion());↵ | |
28 | things = s.createQuery("from Thing").list();↵ | 33 | ↵ | |
29 | assertEquals(1, things.size());↵ | 34 | assertTrue( Hibernate.isInitialized( gavin.getThings() ) );↵ | |
30 | thing = (Thing)things.get(0);↵ | 35 | ↵ | |
31 | assertNull(thing.getName()↵ | 36 | s = openSession();↵ | |
32 | );↵ | 37 | t = s.beginTransaction();↵ | |
33 | s.delete(thing);↵ | 38 | s.delete(gavin);↵ | |
34 | t.commit();↵ | 39 | t.commit();↵ | |
35 | s.close(); | 40 |
| |
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 Thing("Passport", gavin); | ||||||||||||||||||||||||
4 | thing.setName("one"); |
| 15 | assertEquals(1, gavin.getVersion()); | ||||||||||||||||||||||
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); | ||||||||||||||||||||||
|
| 11 | gavin = (Person)s.createCriteria(Person.class).uniqueResult(); | |||||||||||||||||||||||
| 12 | new Thing("Laptop", gavin); | ||||||||||||||||||||||||
12 | thing = (Thing)things.get(0); |
| | |||||||||||||||||||||||
13 | assertEquals("one", thing.getName()); |
| 20 | gavin.getThings().clear(); | ||||||||||||||||||||||
14 | t.commit(); | 13 | t.commit(); | |||||||||||||||||||||||
15 | s.close(); | 14 | s.close(); | |||||||||||||||||||||||
16 | thing.setName(null); |
| 16 | assertFalse(Hibernate.isInitialized(gavin.getThings())); | ||||||||||||||||||||||
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(2, 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.getThings())); | ||||||||||||||||||||||
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 | Expression thing.setName("one") is a void method call, and thus it cannot be parameterized |
2 | Expression assertEquals(1,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
3 | Expression thing.setName("one") is a void method call, and thus it cannot be parameterized |
4 | Expression assertEquals(1,gavin.getVersion()) 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 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 |
14 | 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 |
15 | Expression assertEquals("one",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression assertEquals("one",thing.getName()) is a void method call, and thus it cannot be parameterized |
17 | Expression gavin.getThings().clear() is a void method call, and thus it cannot be parameterized |
18 | Expression assertEquals("one",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression assertEquals("one",thing.getName()) is a void method call, and thus it cannot be parameterized |
20 | Expression gavin.getThings().clear() is a void method call, and thus it cannot be parameterized |
21 | Expression thing.setName(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression thing.setName(null) is a void method call, and thus it cannot be parameterized |
23 | Expression assertFalse(Hibernate.isInitialized(gavin.getThings())) is a void method call, and thus it cannot be parameterized |
24 | Expression thing.setName(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression thing.setName(null) is a void method call, and thus it cannot be parameterized |
26 | Expression assertFalse(Hibernate.isInitialized(gavin.getThings())) 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(2,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(2,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.getThings())) 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.getThings())) 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 assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
41 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
42 | Expression assertEquals(0,gavin.getVersion()) is a void method call, and thus it cannot be parameterized |
43 | Expression assertNull(thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
44 | Expression assertNull(thing.getName()) is a void method call, and thus it cannot be parameterized |
45 | Expression assertEquals(0,gavin.getVersion()) 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 |