File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/SaveOrUpdateTest.java | |||
Method name: void testImplicitSelectEntityAssociationInShallowQuery()
|
Method name: void testSaveOrUpdateManaged()
|
|||
Number of AST nodes: 25 | Number of AST nodes: 21 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | s.beginTransaction();↵ | 2 | Transaction tx = s.beginTransaction();↵ | |
3 | SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation( "owner" );↵ | 3 | ↵ | |
4 | SimpleAssociatedEntity e1 = new SimpleAssociatedEntity( "thing one", owner );↵ | |||
5 | SimpleAssociatedEntity e2 = new SimpleAssociatedEntity↵ | 4 | NumberedNode root = new NumberedNode( "root" );↵ | |
5 | s.saveOrUpdate( root );↵ | |||
6 | tx.commit();↵ | |||
7 | tx = s.beginTransaction();↵ | |||
6 | ( "thing two" );↵ | 8 | NumberedNode child = new NumberedNode( "child" );↵ | |
7 | s.save( e1 );↵ | 9 | ↵ | |
8 | s.save( e2 );↵ | |||
9 | s.save( owner );↵ | |||
10 | s.getTransaction().commit(↵ | 10 | root.addChild( child );↵ | |
11 | s.saveOrUpdate( root );↵ | |||
11 | );↵ | 12 | assertFalse( s.contains( child ) );↵ | |
12 | s.close();↵ | 13 | s.flush();↵ | |
13 | s = openSession();↵ | 14 | ↵ | |
14 | s.beginTransaction();↵ | |||
15 | int count = determineCount( s.createQuery( "select e.id, e.owner from SimpleAssociatedEntity e" ).list().iterator() );↵ | |||
16 | assertEquals( 1, count ); // thing two would be removed from the result due to the inner join↵ | |||
17 | count = determineCount( s.createQuery( "select e.id, e.owner from SimpleAssociatedEntity e" ).iterate() ↵ | 15 | assertTrue( s.contains( child ) );↵ | |
16 | tx.commit();↵ | |||
17 | assertTrue( root.getChildren().contains( child ) );↵ | |||
18 | assertEquals( root.getChildren().size(), 1 );↵ | |||
18 | );↵ | 19 | tx = s.beginTransaction();↵ | |
19 | assertEquals( 1, count );↵ | 20 | assertEquals(↵ | |
20 | s.getTransaction().commit();↵ | |||
21 | s.close();↵ | |||
22 | s = openSession();↵ | |||
23 | s.beginTransaction↵ | |||
21 | s.createCriteria( NumberedNode.class )↵ | |||
22 | .setProjection( Projections.rowCount() )↵ | |||
24 | ();↵ | 23 | .uniqueResult(),↵ | |
25 | s.delete( e1 ↵ | 24 | new Integer( 2 )↵ | |
26 | );↵ | 25 | );↵ | |
27 | s.delete( e2 );↵ | 26 | s.delete( root );↵ | |
28 | s.delete( owner );↵ | 27 | s.delete( child );↵ | |
29 | s.getTransaction().commit();↵ | 28 | tx.commit();↵ | |
30 | 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 in different classes having the same super class |
Number of node comparisons | 525 |
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 19 |
Number of unmapped statements in the second code fragment | 15 |
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 tx = s.beginTransaction(); | ||||||||||||||||||||||
2 | s.beginTransaction(); |
| | ||||||||||||||||||||||
|
| 3 | NumberedNode root = new NumberedNode("root"); | ||||||||||||||||||||||
3 | SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation("owner"); |
| | ||||||||||||||||||||||
|
| 4 | s.saveOrUpdate(root); | ||||||||||||||||||||||
4 | SimpleAssociatedEntity e1 = new SimpleAssociatedEntity("thing one", owner); |
| | ||||||||||||||||||||||
5 | SimpleAssociatedEntity e2 = new SimpleAssociatedEntity("thing two"); |
| | ||||||||||||||||||||||
|
| 6 | tx = s.beginTransaction(); | ||||||||||||||||||||||
6 | s.save(e1); |
| | ||||||||||||||||||||||
|
| 7 | NumberedNode child = new NumberedNode("child"); | ||||||||||||||||||||||
7 | s.save(e2); |
| | ||||||||||||||||||||||
|
| 8 | root.addChild(child); | ||||||||||||||||||||||
8 | s.save(owner); |
| | ||||||||||||||||||||||
|
| 9 | s.saveOrUpdate(root); | ||||||||||||||||||||||
9 | s.getTransaction().commit(); |
| | ||||||||||||||||||||||
|
| 10 | assertFalse(s.contains(child)); | ||||||||||||||||||||||
|
| 11 | s.flush(); | ||||||||||||||||||||||
|
| 12 | assertTrue(s.contains(child)); | ||||||||||||||||||||||
|
| 16 | tx = s.beginTransaction(); | ||||||||||||||||||||||
|
| 17 | assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(), new Integer(2)); | ||||||||||||||||||||||
|
| 18 | s.delete(root); | ||||||||||||||||||||||
|
| 19 | s.delete(child); | ||||||||||||||||||||||
|
| 20 | tx.commit(); | ||||||||||||||||||||||
10 | s.close(); | 21 | s.close(); | ||||||||||||||||||||||
11 | s = openSession(); |
| | ||||||||||||||||||||||
12 | s.beginTransaction(); | | |||||||||||||||||||||||
13 | int count = determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").list().iterator()); | | |||||||||||||||||||||||
14 | assertEquals(1, count); |
| 14 | assertTrue(root.getChildren().contains(child)); | |||||||||||||||||||||
15 | count = determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").iterate()); |
| | ||||||||||||||||||||||
16 | assertEquals(1, count); |
| 15 | assertEquals(root.getChildren().size(), 1); | |||||||||||||||||||||
17 | s.getTransaction().commit(); |
| 13 | tx.commit(); | |||||||||||||||||||||
18 | s.close(); | | |||||||||||||||||||||||
19 | s = openSession(); |
| | ||||||||||||||||||||||
20 | s.beginTransaction(); | | |||||||||||||||||||||||
21 | s.delete(e1); | | |||||||||||||||||||||||
22 | s.delete(e2); | | |||||||||||||||||||||||
23 | s.delete(owner); | | |||||||||||||||||||||||
24 | s.getTransaction().commit(); |
| 5 | tx.commit(); | |||||||||||||||||||||
25 | s.close(); | |
Row | Violation |
---|---|
1 | Unmatched statement Transaction tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement NumberedNode root=new NumberedNode("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement SimpleEntityWithAssociation owner=new SimpleEntityWithAssociation("owner"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement SimpleAssociatedEntity e1=new SimpleAssociatedEntity("thing one",owner); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Unmatched statement SimpleAssociatedEntity e2=new SimpleAssociatedEntity("thing two"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
8 | Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement s.save(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Unmatched statement NumberedNode child=new NumberedNode("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
11 | Unmatched statement s.save(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
13 | Unmatched statement s.save(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched statement assertFalse(s.contains(child)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Unmatched statement assertTrue(s.contains(child)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Unmatched statement assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Unmatched statement s.delete(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | 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 |
23 | Unmatched statement tx.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Expression assertEquals(1,count) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression assertTrue(root.getChildren().contains(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized |
28 | Expression assertTrue(root.getChildren().contains(child)) is a void method call, and thus it cannot be parameterized |
29 | Expression assertEquals(1,count) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression assertTrue(root.getChildren().contains(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
31 | Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized |
32 | Expression assertTrue(root.getChildren().contains(child)) is a void method call, and thus it cannot be parameterized |
33 | Unmatched statement count=determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").iterate()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
34 | Expression root.getChildren().size() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
35 | Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted |
36 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
37 | Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted |
38 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
39 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
40 | Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted |