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 | 10 |
Number of unmapped statements in the first code fragment | 15 |
Number of unmapped statements in the second code fragment | 11 |
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 | SimpleAssociatedEntity e1 = new SimpleAssociatedEntity("thing one", owner); | | ||||||||||||||||||||||||
5 | SimpleAssociatedEntity e2 = new SimpleAssociatedEntity("thing two"); | | ||||||||||||||||||||||||
6 | s.save(e1); | | ||||||||||||||||||||||||
7 | s.save(e2); | | ||||||||||||||||||||||||
8 | s.save(owner); | | ||||||||||||||||||||||||
9 | s.getTransaction().commit(); |
| 5 | 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); |
| 9 | s.saveOrUpdate(root); | ||||||||||||||||||||||
15 | count = determineCount(s.createQuery("select e.id, e.owner from SimpleAssociatedEntity e").iterate()); |
| | |||||||||||||||||||||||
16 | assertEquals(1, count); |
| 4 | s.saveOrUpdate(root); | ||||||||||||||||||||||
|
| 6 | tx = s.beginTransaction(); | |||||||||||||||||||||||
| 7 | NumberedNode child = new NumberedNode("child"); | ||||||||||||||||||||||||
| 8 | root.addChild(child); | ||||||||||||||||||||||||
17 | s.getTransaction().commit(); |
| 12 | assertTrue(s.contains(child)); | ||||||||||||||||||||||
|
| 13 | tx.commit(); | |||||||||||||||||||||||
| 14 | assertTrue(root.getChildren().contains(child)); | ||||||||||||||||||||||||
| 16 | tx = s.beginTransaction(); | ||||||||||||||||||||||||
18 | s.close(); | | ||||||||||||||||||||||||
19 | s = openSession(); |
| | |||||||||||||||||||||||
20 | s.beginTransaction(); | | ||||||||||||||||||||||||
21 | s.delete(e1); |
| 17 | assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(), new Integer(2)); | ||||||||||||||||||||||
22 | s.delete(e2); |
| 15 | assertEquals(root.getChildren().size(), 1); | ||||||||||||||||||||||
23 | s.delete(owner); |
| 11 | s.flush(); | ||||||||||||||||||||||
24 | s.getTransaction().commit(); |
| 10 | assertFalse(s.contains(child)); | ||||||||||||||||||||||
| 18 | s.delete(root); | ||||||||||||||||||||||||
| 19 | s.delete(child); | ||||||||||||||||||||||||
| 20 | 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 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Expression s.saveOrUpdate(root) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized |
6 | Expression s.saveOrUpdate(root) is a void method call, and thus it cannot be parameterized |
7 | Expression s.saveOrUpdate(root) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized |
9 | Expression s.saveOrUpdate(root) is a void method call, and thus it cannot be parameterized |
10 | 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 |
11 | Expression s.saveOrUpdate(root) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized |
13 | Expression s.saveOrUpdate(root) is a void method call, and thus it cannot be parameterized |
14 | Expression s.saveOrUpdate(root) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized |
16 | Expression s.saveOrUpdate(root) is a void method call, and thus it cannot be parameterized |
17 | 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 |
18 | Expression assertTrue(s.contains(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression s.getTransaction().commit() is a void method call, and thus it cannot be parameterized |
20 | Expression assertTrue(s.contains(child)) is a void method call, and thus it cannot be parameterized |
21 | Expression assertTrue(s.contains(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression s.getTransaction().commit() is a void method call, and thus it cannot be parameterized |
23 | Expression assertTrue(s.contains(child)) is a void method call, and thus it cannot be parameterized |
24 | Unmatched statement tx.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression s.delete(e1) is a void method call, and thus it cannot be parameterized |
28 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) is a void method call, and thus it cannot be parameterized |
29 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression s.delete(e1) is a void method call, and thus it cannot be parameterized |
31 | Expression assertEquals(s.createCriteria(NumberedNode.class).setProjection(Projections.rowCount()).uniqueResult(),new Integer(2)) is a void method call, and thus it cannot be parameterized |
32 | Expression s.delete(e2) is a void method call, and thus it cannot be parameterized |
33 | Expression assertEquals(root.getChildren().size(),1) is a void method call, and thus it cannot be parameterized |
34 | Expression s.delete(e2) is a void method call, and thus it cannot be parameterized |
35 | Expression assertEquals(root.getChildren().size(),1) is a void method call, and thus it cannot be parameterized |
36 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
37 | Expression s.delete(owner) is a void method call, and thus it cannot be parameterized |
38 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
39 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
40 | Expression s.delete(owner) is a void method call, and thus it cannot be parameterized |
41 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
42 | Expression assertFalse(s.contains(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
43 | Expression s.getTransaction().commit() is a void method call, and thus it cannot be parameterized |
44 | Expression assertFalse(s.contains(child)) is a void method call, and thus it cannot be parameterized |
45 | Expression assertFalse(s.contains(child)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
46 | Expression s.getTransaction().commit() is a void method call, and thus it cannot be parameterized |
47 | Expression assertFalse(s.contains(child)) is a void method call, and thus it cannot be parameterized |