File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/DeleteTest.java | |||
Method name: void testAllParams()
|
Method name: void testDeleteVersionedWithCollectionNoUpdate()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 19 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession(); ↵ | |
2 | Transaction tx = s.beginTransaction();↵ | 2 | s.beginTransaction(); ↵ | |
3 | Radio radio = new Radio();↵ | 3 | ↵ | |
4 | radio.setFrequency("32 MHz");↵ | 4 | VersionedEntity c = new VersionedEntity( "c1", "child-1" ); ↵ | |
5 | s.persist(radio);↵ | 5 | Versi↵ | |
6 | assertEquals( new Integer(1), radio.getId() );↵ | 6 | onedEntity p = new VersionedEntity( "root", "root"); ↵ | |
7 | radio = new Radio();↵ | 7 | p.getChildren().add( c ); ↵ | |
8 | radio.setFrequency("32 MHz");↵ | 8 | c.setParent( p ); ↵ | |
9 | s.persist(radio);↵ | 9 | s.save( p ); ↵ | |
10 | assertEquals( new Integer(2), radio.getId() );↵ | 10 | ↵ | |
11 | tx.commit();↵ | 11 | s.getTransaction().commit(); ↵ | |
12 | s.close();↵ | 12 | s.close();↵ | |
13 | ↵ | |||
13 | clearCounts();↵ | |||
14 | ↵ | |||
14 | s = openSession();↵ | 15 | s = openSession(); ↵ | |
15 | tx = s.beginTransaction();↵ | 16 | s.beginTransaction();↵ | |
16 | s.createQuery( "delete from Radio" ).executeUpdate(↵ | |||
17 | VersionedEntity loadedParent = ( VersionedEntity ) s.get( VersionedEntity.class, "root" );↵ | |||
17 | );↵ | 18 | s.delete( loadedParent ); ↵ | |
18 | tx.commit();↵ | 19 | ↵ | |
19 | s.close(↵ | 20 | s.getTransaction().commit();↵ | |
21 | s.close();↵ | |||
22 | assertInsertCount( 0 );↵ | |||
23 | assertUpdateCount( 0 );↵ | |||
20 | ); | 24 | assertDeleteCount( 2 ); | |
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 | 259 |
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 11 |
Number of unmapped statements in the second code fragment | 13 |
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 | s.beginTransaction(); | |||||||||||||||||||||||
2 | Transaction tx = s.beginTransaction(); |
| | |||||||||||||||||||||||
|
| 3 | VersionedEntity c = new VersionedEntity("c1", "child-1"); | |||||||||||||||||||||||
3 | Radio radio = new Radio(); | | ||||||||||||||||||||||||
|
| 4 | VersionedEntity p = new VersionedEntity("root", "root"); | |||||||||||||||||||||||
4 | radio.setFrequency("32 MHz"); |
| | |||||||||||||||||||||||
| 5 | p.getChildren().add(c); | ||||||||||||||||||||||||
5 | s.persist(radio); |
| | |||||||||||||||||||||||
|
| 6 | c.setParent(p); | |||||||||||||||||||||||
|
| 7 | s.save(p); | |||||||||||||||||||||||
|
| 8 | s.getTransaction().commit(); | |||||||||||||||||||||||
6 | assertEquals(new Integer(1), radio.getId()); |
| 10 | clearCounts(); | ||||||||||||||||||||||
7 | radio = new Radio(); |
| | |||||||||||||||||||||||
8 | radio.setFrequency("32 MHz"); |
| | |||||||||||||||||||||||
9 | s.persist(radio); |
| | |||||||||||||||||||||||
10 | assertEquals(new Integer(2), radio.getId()); |
| 18 | assertUpdateCount(0); | ||||||||||||||||||||||
11 | tx.commit(); |
| | |||||||||||||||||||||||
12 | s.close(); | 9 | s.close(); | |||||||||||||||||||||||
13 | s = openSession(); | 11 | s = openSession(); | |||||||||||||||||||||||
|
| 12 | s.beginTransaction(); | |||||||||||||||||||||||
|
| 13 | VersionedEntity loadedParent = (VersionedEntity)s.get(VersionedEntity.class, "root"); | |||||||||||||||||||||||
|
| 14 | s.delete(loadedParent); | |||||||||||||||||||||||
14 | tx = s.beginTransaction(); |
| | |||||||||||||||||||||||
|
| 15 | s.getTransaction().commit(); | |||||||||||||||||||||||
15 | s.createQuery("delete from Radio").executeUpdate(); |
| | |||||||||||||||||||||||
16 | tx.commit(); |
| | |||||||||||||||||||||||
17 | s.close(); | 16 | s.close(); | |||||||||||||||||||||||
| 17 | assertInsertCount(0); | ||||||||||||||||||||||||
| 19 | assertDeleteCount(2); |
Row | Violation |
---|---|
1 | Unmatched statement 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 Transaction tx=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 VersionedEntity c=new VersionedEntity("c1","child-1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement VersionedEntity p=new VersionedEntity("root","root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement s.persist(radio); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement c.setParent(p); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
8 | Unmatched statement s.save(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | 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 |
10 | Expression assertEquals(new Integer(1),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized |
12 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
13 | Expression assertEquals(new Integer(1),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized |
15 | Expression clearCounts() is a void method call, and thus it cannot be parameterized |
16 | Unmatched statement radio=new Radio(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
18 | Unmatched statement s.persist(radio); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Expression assertEquals(new Integer(2),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized |
21 | Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized |
22 | Expression assertEquals(new Integer(2),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized |
24 | Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized |
25 | Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
26 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
27 | Unmatched statement VersionedEntity loadedParent=(VersionedEntity)s.get(VersionedEntity.class,"root"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
28 | Unmatched statement s.delete(loadedParent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
29 | 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 |
30 | 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 |
31 | Unmatched statement s.createQuery("delete from Radio").executeUpdate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
32 | Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |