File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java | |||
Method name: void testUpdateParentWithNewChildCommitWithReadOnlyParent()
|
Method name: void testMergeDetachedChildWithNewParentCommitWithReadOnlyChild()
|
|||
Number of AST nodes: 32 | Number of AST nodes: 32 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | s.beginTransaction();↵ | 2 | s.beginTransaction();↵ | |
3 | VersionedNode parent = new VersionedNode( "parent", "parent" );↵ | 3 | VersionedNode child = new VersionedNode( "child", "child" );↵ | |
4 | s.persist( parent );↵ | 4 | s.persist( child );↵ | |
5 | s.getTransaction().commit();↵ | 5 | s.getTransaction().commit();↵ | |
6 | s.close();↵ | 6 | s.close();↵ | |
7 | clearCounts();↵ | 7 | clearCounts();↵ | |
8 | parent.setName( "new parent name" );↵ | 8 | child.setName( "new child name" );↵ | |
9 | VersionedNode child = new VersionedNode( "child", "child");↵ | 9 | VersionedNode parent = new VersionedNode( "parent", "parent");↵ | |
10 | parent.addChild( child );↵ | 10 | parent.addChild( child );↵ | |
11 | s = openSession();↵ | 11 | s = openSession();↵ | |
12 | s.beginTransaction();↵ | 12 | s.beginTransaction();↵ | |
13 | s.update( parent );↵ | 13 | child = ( VersionedNode ) s.merge( child );↵ | |
14 | s.setReadOnly( parent, true );↵ | 14 | s.setReadOnly( child, true );↵ | |
15 | s.getTransaction().commit();↵ | 15 | s.getTransaction().commit();↵ | |
16 | s.close();↵ | 16 | s.close();↵ | |
17 | assertUpdateCount( 0 );↵ | 17 | assertUpdateCount( 1 );↵ | |
18 | assertInsertCount( 1 );↵ | 18 | assertInsertCount( 1 );↵ | |
19 | s = openSession();↵ | 19 | s = openSession();↵ | |
20 | s.beginTransaction();↵ | 20 | s.beginTransaction();↵ | |
21 | parent = ( VersionedNode ) s.get( VersionedNode.class, parent.getId() );↵ | 21 | parent = ( VersionedNode ) s.get( VersionedNode.class, parent.getId() );↵ | |
22 | child = ( VersionedNode ) s.get( VersionedNode.class, child.getId() );↵ | 22 | child = ( VersionedNode ) s.get( VersionedNode.class, child.getId() );↵ | |
23 | assertEquals( parent.getName(), "parent" );↵ | 23 | assertEquals( child.getName(), "child" );↵ | |
24 | assertEquals( 1, parent.getChildren().size() );↵ | 24 | assertNull( child.getParent() );↵ | |
25 | assertEquals( 0, parent.getVersion() );↵ | 25 | assertEquals( 0, child.getVersion() );↵ | |
26 | assertSame( parent, child.getParent() );↵ | 26 | assertNotNull( parent );↵ | |
27 | assertSame( child, parent.getChildren().iterator().next() );↵ | 27 | assertEquals( 0, parent.getChildren().size() );↵ | |
28 | assertEquals( 0, child.getVersion() );↵ | 28 | assertEquals( 1, parent.getVersion() ); // hmmm, why is was version updated?↵ | |
29 | s.delete( parent );↵ | 29 | s.delete( parent );↵ | |
30 | s.delete( child );↵ | 30 | s.delete( child );↵ | |
31 | s.getTransaction().commit();↵ | 31 | s.getTransaction().commit();↵ | |
32 | s.close(); | 32 |
| |
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 | 363 |
Number of mapped statements | 29 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 1 | Session s = openSession(); | |||||||||||||||||||||||
2 | s.beginTransaction(); | 2 | s.beginTransaction(); | |||||||||||||||||||||||
3 | VersionedNode parent = new VersionedNode("parent", "parent"); | 9 | VersionedNode parent = new VersionedNode("parent", "parent"); | |||||||||||||||||||||||
4 | s.persist(parent); |
| 4 | s.persist(child); | ||||||||||||||||||||||
5 | s.getTransaction().commit(); | 5 | s.getTransaction().commit(); | |||||||||||||||||||||||
6 | s.close(); | 6 | s.close(); | |||||||||||||||||||||||
7 | clearCounts(); | 7 | clearCounts(); | |||||||||||||||||||||||
8 | parent.setName("new parent name"); |
| 8 | child.setName("new child name"); | ||||||||||||||||||||||
9 | VersionedNode child = new VersionedNode("child", "child"); | 3 | VersionedNode child = new VersionedNode("child", "child"); | |||||||||||||||||||||||
10 | parent.addChild(child); | 10 | parent.addChild(child); | |||||||||||||||||||||||
11 | s = openSession(); | 11 | s = openSession(); | |||||||||||||||||||||||
12 | s.beginTransaction(); | 12 | s.beginTransaction(); | |||||||||||||||||||||||
13 | s.update(parent); |
| 29 | s.delete(parent); | ||||||||||||||||||||||
14 | s.setReadOnly(parent, true); |
| 30 | s.delete(child); | ||||||||||||||||||||||
15 | s.getTransaction().commit(); | 15 | s.getTransaction().commit(); | |||||||||||||||||||||||
16 | s.close(); | 16 | s.close(); | |||||||||||||||||||||||
17 | assertUpdateCount(0); |
| 17 | assertUpdateCount(1); | ||||||||||||||||||||||
18 | assertInsertCount(1); | 18 | assertInsertCount(1); | |||||||||||||||||||||||
19 | s = openSession(); | 19 | s = openSession(); | |||||||||||||||||||||||
20 | s.beginTransaction(); | 20 | s.beginTransaction(); | |||||||||||||||||||||||
21 | parent = (VersionedNode)s.get(VersionedNode.class, parent.getId()); |
| 13 | child = (VersionedNode)s.merge(child); | ||||||||||||||||||||||
22 | child = (VersionedNode)s.get(VersionedNode.class, child.getId()); |
| 21 | parent = (VersionedNode)s.get(VersionedNode.class, parent.getId()); | ||||||||||||||||||||||
|
| 22 | child = (VersionedNode)s.get(VersionedNode.class, child.getId()); | |||||||||||||||||||||||
23 | assertEquals(parent.getName(), "parent"); |
| 23 | assertEquals(child.getName(), "child"); | ||||||||||||||||||||||
24 | assertEquals(1, parent.getChildren().size()); |
| | |||||||||||||||||||||||
25 | assertEquals(0, parent.getVersion()); |
| | |||||||||||||||||||||||
26 | assertSame(parent, child.getParent()); |
| 24 | assertNull(child.getParent()); | ||||||||||||||||||||||
| 25 | assertEquals(0, child.getVersion()); | ||||||||||||||||||||||||
27 | assertSame(child, parent.getChildren().iterator().next()); |
| 26 | assertNotNull(parent); | ||||||||||||||||||||||
|
| 27 | assertEquals(0, parent.getChildren().size()); | |||||||||||||||||||||||
28 | assertEquals(0, child.getVersion()); |
| 28 | assertEquals(1, parent.getVersion()); | ||||||||||||||||||||||
29 | s.delete(parent); |
| 14 | s.setReadOnly(child, true); | ||||||||||||||||||||||
30 | s.delete(child); |
| | |||||||||||||||||||||||
31 | s.getTransaction().commit(); | 31 | s.getTransaction().commit(); | |||||||||||||||||||||||
32 | s.close(); | 32 | s.close(); |
Row | Violation |
---|---|
1 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression s.update(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression s.update(parent) is a void method call, and thus it cannot be parameterized |
8 | Expression s.delete(parent) is a void method call, and thus it cannot be parameterized |
9 | Expression s.setReadOnly(parent,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression s.delete(child) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression s.setReadOnly(parent,true) is a void method call, and thus it cannot be parameterized |
12 | Expression s.delete(child) is a void method call, and thus it cannot be parameterized |
13 | Expression s.setReadOnly(parent,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression s.delete(child) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression s.setReadOnly(parent,true) is a void method call, and thus it cannot be parameterized |
16 | Expression s.delete(child) is a void method call, and thus it cannot be parameterized |
17 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression s.get(VersionedNode.class,parent.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression s.merge(child) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression s.get(VersionedNode.class,parent.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression s.merge(child) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Unmatched statement child=(VersionedNode)s.get(VersionedNode.class,child.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
28 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Unmatched statement assertEquals(1,parent.getChildren().size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
31 | Unmatched statement assertEquals(0,parent.getVersion()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
32 | Expression assertSame(parent,child.getParent()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
33 | Expression assertNull(child.getParent()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
34 | Expression assertSame(parent,child.getParent()) is a void method call, and thus it cannot be parameterized |
35 | Expression assertNull(child.getParent()) is a void method call, and thus it cannot be parameterized |
36 | Expression assertSame(parent,child.getParent()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
37 | Expression assertNull(child.getParent()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
38 | Expression assertSame(parent,child.getParent()) is a void method call, and thus it cannot be parameterized |
39 | Expression assertNull(child.getParent()) is a void method call, and thus it cannot be parameterized |
40 | Expression assertSame(child,parent.getChildren().iterator().next()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
41 | Expression assertNotNull(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
42 | Expression assertSame(child,parent.getChildren().iterator().next()) is a void method call, and thus it cannot be parameterized |
43 | Expression assertNotNull(parent) is a void method call, and thus it cannot be parameterized |
44 | Expression assertSame(child,parent.getChildren().iterator().next()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
45 | Expression assertNotNull(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
46 | Expression assertSame(child,parent.getChildren().iterator().next()) is a void method call, and thus it cannot be parameterized |
47 | Expression assertNotNull(parent) is a void method call, and thus it cannot be parameterized |
48 | Unmatched statement assertEquals(0,parent.getChildren().size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
49 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
50 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
51 | Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
52 | Expression s.setReadOnly(child,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
53 | Expression s.delete(parent) is a void method call, and thus it cannot be parameterized |
54 | Expression s.setReadOnly(child,true) is a void method call, and thus it cannot be parameterized |
55 | Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
56 | Expression s.setReadOnly(child,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
57 | Expression s.delete(parent) is a void method call, and thus it cannot be parameterized |
58 | Expression s.setReadOnly(child,true) is a void method call, and thus it cannot be parameterized |
59 | Unmatched statement s.delete(child); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
60 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables child, s |