File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/SaveOrUpdateTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/SaveOrUpdateTest.java | |||
Method name: void testSaveOrUpdateTree()
|
Method name: void testSaveOrUpdateTreeWithGeneratedId()
|
|||
Number of AST nodes: 28 | Number of AST nodes: 28 | |||
1 | clearCounts();↵ | 1 | clearCounts();↵ | |
2 | Session s = openSession();↵ | 2 | Session s = openSession();↵ | |
3 | Transaction tx = s.beginTransaction();↵ | 3 | Transaction tx = s.beginTransaction();↵ | |
4 | Node root = new Node( "root" );↵ | 4 | NumberedNode root = new NumberedNode( "root" );↵ | |
5 | Node child = new Node( "child" );↵ | 5 | NumberedNode child = new NumberedNode( "child" );↵ | |
6 | root.addChild( child );↵ | 6 | root.addChild( child );↵ | |
7 | s.saveOrUpdate( root );↵ | 7 | s.saveOrUpdate( root );↵ | |
8 | tx.commit();↵ | 8 | tx.commit();↵ | |
9 | s.close();↵ | 9 | s.close();↵ | |
10 | assertInsertCount( 2 );↵ | 10 | assertInsertCount( 2 );↵ | |
11 | clearCounts();↵ | 11 | clearCounts();↵ | |
12 | root.setDescription( "The root node" );↵ | 12 | root.setDescription( "The root node" );↵ | |
13 | child.setDescription( "The child node" );↵ | 13 | child.setDescription( "The child node" );↵ | |
14 | Node secondChild = new Node( "second child" );↵ | 14 | NumberedNode secondChild = new NumberedNode( "second child" );↵ | |
15 | root.addChild( secondChild );↵ | 15 | root.addChild( secondChild );↵ | |
16 | s = openSession();↵ | 16 | s = openSession();↵ | |
17 | tx = s.beginTransaction();↵ | 17 | tx = s.beginTransaction();↵ | |
18 | s.saveOrUpdate( root );↵ | 18 | s.saveOrUpdate( root );↵ | |
19 | tx.commit();↵ | 19 | tx.commit();↵ | |
20 | s.close();↵ | 20 | s.close();↵ | |
21 | assertInsertCount( 1 );↵ | 21 | assertInsertCount( 1 );↵ | |
22 | assertUpdateCount( 2 );↵ | 22 | assertUpdateCount( 2 );↵ | |
23 | s = openSession();↵ | 23 | s = openSession();↵ | |
24 | tx = s.beginTransaction();↵ | 24 | tx = s.beginTransaction();↵ | |
25 | s.createQuery( "delete from Node where parent is not null" ).executeUpdate();↵ | 25 | s.createQuery( "delete from NumberedNode where parent is not null" ).executeUpdate();↵ | |
26 | s.createQuery( "delete from Node" ).executeUpdate();↵ | 26 | s.createQuery( "delete from NumberedNode" ).executeUpdate();↵ | |
27 | tx.commit();↵ | 27 | tx.commit();↵ | |
28 | s.close(); | 28 |
| |
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 | 206 |
Number of mapped statements | 23 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | clearCounts(); | 1 | clearCounts(); | ||||||||||||
2 | Session s = openSession(); | 2 | Session s = openSession(); | ||||||||||||
3 | Transaction tx = s.beginTransaction(); | 3 | Transaction tx = s.beginTransaction(); | ||||||||||||
| 4 | NumberedNode root = new NumberedNode("root"); | |||||||||||||
4 | Node root = new Node("root"); | | |||||||||||||
| 5 | NumberedNode child = new NumberedNode("child"); | |||||||||||||
5 | Node child = new Node("child"); | | |||||||||||||
| 6 | root.addChild(child); | |||||||||||||
6 | root.addChild(child); | | |||||||||||||
7 | s.saveOrUpdate(root); |
| 7 | s.saveOrUpdate(root); | |||||||||||
8 | tx.commit(); | 8 | tx.commit(); | ||||||||||||
9 | s.close(); | 9 | s.close(); | ||||||||||||
10 | assertInsertCount(2); | 10 | assertInsertCount(2); | ||||||||||||
11 | clearCounts(); | 11 | clearCounts(); | ||||||||||||
12 | root.setDescription("The root node"); |
| 12 | root.setDescription("The root node"); | |||||||||||
13 | child.setDescription("The child node"); |
| 13 | child.setDescription("The child node"); | |||||||||||
| 14 | NumberedNode secondChild = new NumberedNode("second child"); | |||||||||||||
14 | Node secondChild = new Node("second child"); | | |||||||||||||
| 15 | root.addChild(secondChild); | |||||||||||||
15 | root.addChild(secondChild); | | |||||||||||||
16 | s = openSession(); | 16 | s = openSession(); | ||||||||||||
17 | tx = s.beginTransaction(); | 17 | tx = s.beginTransaction(); | ||||||||||||
18 | s.saveOrUpdate(root); |
| 18 | s.saveOrUpdate(root); | |||||||||||
19 | tx.commit(); | 19 | tx.commit(); | ||||||||||||
20 | s.close(); | 20 | s.close(); | ||||||||||||
21 | assertInsertCount(1); | 21 | assertInsertCount(1); | ||||||||||||
22 | assertUpdateCount(2); | 22 | assertUpdateCount(2); | ||||||||||||
23 | s = openSession(); | 23 | s = openSession(); | ||||||||||||
24 | tx = s.beginTransaction(); | 24 | tx = s.beginTransaction(); | ||||||||||||
25 | s.createQuery("delete from Node where parent is not null").executeUpdate(); |
| 25 | s.createQuery("delete from NumberedNode where parent is not null").executeUpdate(); | |||||||||||
26 | s.createQuery("delete from Node").executeUpdate(); |
| 26 | s.createQuery("delete from NumberedNode").executeUpdate(); | |||||||||||
27 | tx.commit(); | 27 | tx.commit(); | ||||||||||||
28 | s.close(); | 28 | s.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root |
2 | Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root |
3 | Type org.hibernate.test.ops.Node of variable child does not match with type org.hibernate.test.ops.NumberedNode of variable child |
4 | Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root |