Session s = openSession(); Transaction tx = s.beginTransaction(); Radio radio = new Radio(); radio.setFrequency("32 MHz"); s.persist(radio); assertEquals( new Integer(1), radio.getId() ); radio = new Radio(); radio.setFrequency("32 MHz"); s.persist(radio); assertEquals( new Integer(2), radio.getId() ); tx.commit(); s.close(); s = openSession(); tx = s.beginTransaction(); s.createQuery( "delete from Radio" ).executeUpdate(); tx.commit(); s.close();
Session s = openSession(); s.beginTransaction(); VersionedEntity c = new VersionedEntity( "c1", "child-1" ); VersionedEntity p = new VersionedEntity( "root", "root"); p.getChildren().add( c ); c.setParent( p ); s.save( p ); s.getTransaction().commit(); s.close(); clearCounts(); s = openSession(); s.beginTransaction(); VersionedEntity loadedParent = ( VersionedEntity ) s.get( VersionedEntity.class, "root" ); s.delete( loadedParent ); s.getTransaction().commit(); s.close(); assertInsertCount( 0 ); assertUpdateCount( 0 ); assertDeleteCount( 2 );
Clone fragments detected by clone detection tool
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 );
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in different classes having the same super class
Number of node comparisons259
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment11
    Number of unmapped statements in the second code fragment13
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
                                                    
    2
    s.beginTransaction();
    Preondition Violations
    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
    s.beginTransaction();
    2
    Transaction tx = s.beginTransaction();
    2
    Transaction tx = s.beginTransaction();
    Preondition Violations
    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
    VersionedEntity c = new VersionedEntity("c1", "child-1");
    Preondition Violations
    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
    3
    VersionedEntity c = new VersionedEntity("c1", "child-1");
    3
    Radio radio = new Radio();
                                                          
                                                                                                                    
    4
    VersionedEntity p = new VersionedEntity("root", "root");
    Preondition Violations
    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
    4
    VersionedEntity p = new VersionedEntity("root", "root");
    4
    radio.setFrequency("32 MHz");
    4
    radio.setFrequency("32 MHz");
    Preondition Violations
    Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                    
                                                        
    5
    p.getChildren().add(c);
    5
    s.persist(radio);
    5
    s.persist(radio);
    Preondition Violations
    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
                                            
                                        
    6
    c.setParent(p);
    Preondition Violations
    Unmatched statement c.setParent(p); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6
    c.setParent(p);
                              
    7
    s.save(p);
    Preondition Violations
    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
    7
    s.save(p);
                                                                  
    8
    s.getTransaction().commit();
    Preondition Violations
    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
    8
    s.getTransaction().commit();
    6
    assertEquals(new Integer(1), radio.getId());
    6
    assertEquals(new Integer(1), radio.getId());
    10
    clearCounts();
    Differences
    Expression1Expression2Difference
    assertEqualsclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(new Integer(1),radio.getId())clearCounts()TYPE_COMPATIBLE_REPLACEMENT
    assertEquals(new Integer(1),radio.getId())clearCounts()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(new Integer(1),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression assertEquals(new Integer(1),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    10
    clearCounts();
    7
    radio = new Radio();
    7
    radio = new Radio();
    Preondition Violations
    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
                                              
    8
    radio.setFrequency("32 MHz");
    8
    radio.setFrequency("32 MHz");
    Preondition Violations
    Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                    
    9
    s.persist(radio);
    9
    s.persist(radio);
    Preondition Violations
    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
                                            
    10
    assertEquals(new Integer(2), radio.getId());
    10
    assertEquals(new Integer(2), radio.getId());
    18
    assertUpdateCount(0);
    Differences
    Expression1Expression2Difference
    assertEqualsassertUpdateCountMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(new Integer(2),radio.getId())assertUpdateCount(0)TYPE_COMPATIBLE_REPLACEMENT
    assertEquals(new Integer(2),radio.getId())assertUpdateCount(0)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(new Integer(2),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(new Integer(2),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    18
    assertUpdateCount(0);
    11
    tx.commit();
    11
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                    
    12
    s.close();
    9
    s.close();
    13
    s = openSession();
    11
    s = openSession();
                                                      
    12
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    s.beginTransaction();
                                                                                                                                                                                
    13
    VersionedEntity loadedParent = (VersionedEntity)s.get(VersionedEntity.class, "root");
    Preondition Violations
    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
    13
    VersionedEntity loadedParent = (VersionedEntity)s.get(VersionedEntity.class, "root");
                                                          
    14
    s.delete(loadedParent);
    Preondition Violations
    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
    14
    s.delete(loadedParent);
    14
    tx = s.beginTransaction();
    14
    tx = s.beginTransaction();
    Preondition Violations
    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
                                                            
                                                                    
    15
    s.getTransaction().commit();
    Preondition Violations
    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
    15
    s.getTransaction().commit();
    15
    s.createQuery("delete from Radio").executeUpdate();
    15
    s.createQuery("delete from Radio").executeUpdate();
    Preondition Violations
    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
                                                                                                                  
    16
    tx.commit();
    16
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                    
    17
    s.close();
    16
    s.close();
                                                      
    17
    assertInsertCount(0);
                                                      
    19
    assertDeleteCount(2);
    Precondition Violations (32)
    Row Violation
    1Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched 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
    3Unmatched 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
    4Unmatched 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
    5Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement s.persist(radio); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement c.setParent(p); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement s.save(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Expression assertEquals(new Integer(1),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized
    12Expression clearCounts() is a void method call, and thus it cannot be parameterized
    13Expression assertEquals(new Integer(1),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized
    15Expression clearCounts() is a void method call, and thus it cannot be parameterized
    16Unmatched statement radio=new Radio(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    18Unmatched statement s.persist(radio); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Expression assertEquals(new Integer(2),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    21Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    22Expression assertEquals(new Integer(2),radio.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    24Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    25Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    26Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Unmatched 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
    28Unmatched statement s.delete(loadedParent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    30Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    31Unmatched 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
    32Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted