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/join/OptionalJoinTest.java | |||
Method name: void testMergeNonNullOptionalJoinToNullDetached()
|
Method name: void testUpdateNullOptionalJoinToNonNull()
|
|||
Number of AST nodes: 30 | Number of AST nodes: 26 | |||
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 | // create a new thing with a null name↵ | |
4 | Thing thing = new Thing();↵ | 4 | Thing thing = new Thing();↵ | |
5 | thing.setName("one");↵ | 5 | thing.setName(null);↵ | |
6 | s.save(thing);↵ | 6 | s.save(thing);↵ | |
7 | t.commit();↵ | 7 | t.commit();↵ | |
8 | s.close();↵ | 8 | s.close();↵ | |
9 | s = openSession();↵ | 9 | s = openSession();↵ | |
10 | t = s.beginTransaction();↵ | 10 | t = s.beginTransaction();↵ | |
11 | List things = s.createQuery("from Thing").list();↵ | 11 | List things = s.createQuery("from Thing").list();↵ | |
12 | assertEquals(1, things.size());↵ | 12 | assertEquals(1, things.size());↵ | |
13 | thing = (Thing)things.get(0);↵ | 13 | thing = (Thing)things.get(0);↵ | |
14 | assertEquals("one", thing.getName());↵ | 14 | assertNull(thing.getName());↵ | |
15 | t.commit();↵ | 15 | ↵ | |
16 | s.close();↵ | |||
17 | // give detached thing a null name and save it↵ | |||
18 | thing.setName(null);↵ | |||
19 | s = openSession();↵ | |||
20 | t = s.beginTransaction();↵ | |||
21 | s.merg↵ | 16 | // change name to a non-null value↵ | |
17 | thing.setName("two");↵ | |||
22 | e(thing);↵ | 18 | s.update(thing);↵ | |
23 | t.commit();↵ | 19 | t.commit();↵ | |
24 | s.close();↵ | 20 | s.close();↵ | |
25 | s = openSession();↵ | 21 | s = openSession();↵ | |
26 | t = s.beginTransaction();↵ | 22 | t = s.beginTransaction();↵ | |
27 | things = s.createQuery("from Thing").list();↵ | 23 | things = s.createQuery("from Thing").list();↵ | |
28 | assertEquals(1, things.size());↵ | 24 | assertEquals(1, things.size());↵ | |
29 | thing = (Thing)things.get(0);↵ | 25 | thing = ((Thing) things.get(0));↵ | |
30 | assertNull(thing.getName());↵ | 26 | assertEquals("two", thing.getName());↵ | |
31 | s.delete(thing);↵ | 27 | s.delete(thing);↵ | |
32 | t.commit();↵ | 28 | t.commit();↵ | |
33 | s.close(); | 29 |
| |
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 declared in the same class |
Number of node comparisons | 212 |
Number of mapped statements | 26 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 0 |
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 | Thing thing = new Thing(); | 3 | Thing thing = new Thing(); | |||||||||||||||||||||||||
4 | thing.setName("one"); |
| 4 | thing.setName(null); | ||||||||||||||||||||||||
5 | s.save(thing); | 5 | s.save(thing); | |||||||||||||||||||||||||
6 | t.commit(); | 6 | t.commit(); | |||||||||||||||||||||||||
7 | s.close(); | 7 | s.close(); | |||||||||||||||||||||||||
8 | s = openSession(); | 8 | s = openSession(); | |||||||||||||||||||||||||
9 | t = s.beginTransaction(); | 9 | t = s.beginTransaction(); | |||||||||||||||||||||||||
10 | List things = s.createQuery("from Thing").list(); | 10 | List things = s.createQuery("from Thing").list(); | |||||||||||||||||||||||||
11 | assertEquals(1, things.size()); | 11 | assertEquals(1, things.size()); | |||||||||||||||||||||||||
12 | thing = (Thing)things.get(0); | 12 | thing = (Thing)things.get(0); | |||||||||||||||||||||||||
13 | assertEquals("one", thing.getName()); |
| 15 | s.update(thing); | ||||||||||||||||||||||||
14 | t.commit(); | 16 | t.commit(); | |||||||||||||||||||||||||
15 | s.close(); | 17 | s.close(); | |||||||||||||||||||||||||
16 | thing.setName(null); |
| 14 | thing.setName("two"); | ||||||||||||||||||||||||
17 | s = openSession(); | 18 | s = openSession(); | |||||||||||||||||||||||||
18 | t = s.beginTransaction(); | 19 | t = s.beginTransaction(); | |||||||||||||||||||||||||
19 | s.merge(thing); |
| | |||||||||||||||||||||||||
20 | t.commit(); | 25 | t.commit(); | |||||||||||||||||||||||||
21 | s.close(); | | ||||||||||||||||||||||||||
22 | s = openSession(); |
| | |||||||||||||||||||||||||
23 | t = s.beginTransaction(); |
| | |||||||||||||||||||||||||
24 | things = s.createQuery("from Thing").list(); | 20 | things = s.createQuery("from Thing").list(); | |||||||||||||||||||||||||
25 | assertEquals(1, things.size()); | 21 | assertEquals(1, things.size()); | |||||||||||||||||||||||||
26 | thing = (Thing)things.get(0); |
| 22 | thing = ((Thing)things.get(0)); | ||||||||||||||||||||||||
27 | assertNull(thing.getName()); | 13 | assertNull(thing.getName()); | |||||||||||||||||||||||||
28 | s.delete(thing); | 24 | s.delete(thing); | |||||||||||||||||||||||||
29 | t.commit(); |
| 23 | assertEquals("two", thing.getName()); | ||||||||||||||||||||||||
30 | s.close(); | 26 | s.close(); |
Row | Violation |
---|---|
1 | Expression assertEquals("one",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression s.update(thing) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression assertEquals("one",thing.getName()) is a void method call, and thus it cannot be parameterized |
4 | Expression s.update(thing) is a void method call, and thus it cannot be parameterized |
5 | Expression assertEquals("one",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression s.update(thing) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression assertEquals("one",thing.getName()) is a void method call, and thus it cannot be parameterized |
8 | Expression s.update(thing) is a void method call, and thus it cannot be parameterized |
9 | Unmatched statement s.merge(thing); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
11 | 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 |
12 | Expression (Thing)things.get(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression ((Thing)things.get(0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression assertEquals("two",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
17 | Expression assertEquals("two",thing.getName()) is a void method call, and thus it cannot be parameterized |
18 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression assertEquals("two",thing.getName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
21 | Expression assertEquals("two",thing.getName()) is a void method call, and thus it cannot be parameterized |
22 | Clone fragment #1 returns variables thing, s , while Clone fragment #2 returns variables |