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 statements9
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment10
    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");
    3
    Radio radio = new Radio();
                                                          
                                                                                                                    
    4
    VersionedEntity p = new VersionedEntity("root", "root");
                                                        
    5
    p.getChildren().add(c);
                                        
    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);
    4
    radio.setFrequency("32 MHz");
    4
    radio.setFrequency("32 MHz");
    10
    clearCounts();
    Differences
    Expression1Expression2Difference
    setFrequencyclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    radio.setFrequency("32 MHz")clearCounts()ARGUMENT_NUMBER_MISMATCH
    radioMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression radio.setFrequency("32 MHz") 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 radio.setFrequency("32 MHz") 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();
    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
                                            
                                                      
    12
    s.beginTransaction();
                                                                                                                                                                                
    13
    VersionedEntity loadedParent = (VersionedEntity)s.get(VersionedEntity.class, "root");
                                                          
    14
    s.delete(loadedParent);
    6
    assertEquals(new Integer(1), radio.getId());
    6
    assertEquals(new Integer(1), radio.getId());
    18
    assertUpdateCount(0);
    Differences
    Expression1Expression2Difference
    assertEqualsassertUpdateCountMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(new Integer(1),radio.getId())assertUpdateCount(0)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(new Integer(1),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(1),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);
    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 or after the extracted code, because it has dependencies to/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());
    17
    assertInsertCount(0);
    Differences
    Expression1Expression2Difference
    assertEqualsassertInsertCountMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(new Integer(2),radio.getId())assertInsertCount(0)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized
    17
    assertInsertCount(0);
    11
    tx.commit();
    11
    tx.commit();
    8
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    txs.getTransaction()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    s.getTransaction().commit();
    12
    s.close();
    9
    s.close();
    13
    s = openSession();
    11
    s = openSession();
    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.createQuery("delete from Radio").executeUpdate();
                                                                                                                  
    16
    tx.commit();
    16
    tx.commit();
    15
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    txs.getTransaction()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15
    s.getTransaction().commit();
    17
    s.close();
    16
    s.close();
                                                      
    19
    assertDeleteCount(2);
    Precondition Violations (22)
    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 s.save(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression radio.setFrequency("32 MHz") is a void method call, and thus it cannot be parameterized
    5Expression clearCounts() is a void method call, and thus it cannot be parameterized
    6Expression radio.setFrequency("32 MHz") is a void method call, and thus it cannot be parameterized
    7Expression clearCounts() is a void method call, and thus it cannot be parameterized
    8Unmatched statement s.persist(radio); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized
    10Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    11Expression assertEquals(new Integer(1),radio.getId()) is a void method call, and thus it cannot be parameterized
    12Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    13Unmatched statement radio=new Radio(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement radio.setFrequency("32 MHz"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement s.persist(radio); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    17Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized
    18Expression assertEquals(new Integer(2),radio.getId()) is a void method call, and thus it cannot be parameterized
    19Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized
    20Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted