entities[i] = new Entity( "" + ( i + 1 ) ); s.save( entities[i] ); long expectedId = i + 1; assertEquals( expectedId, entities[i].getId().longValue() ); assertEquals( 1, generator.getOptimizer().getLastSourceValue() ); assertEquals( i + 1, optimizer.getLastValue() ); assertEquals( increment + 1, optimizer.getHiValue() );
for ( int i = 0; i < increment; i++ ) { entities[i] = new Entity( "" + ( i + 1 ) ); s.save( entities[i] ); assertEquals( 2, generator.getDatabaseStructure().getTimesAccessed() ); // initialization calls seq twice assertEquals( increment + 1, optimizer.getLastSourceValue() ); // initialization calls seq twice assertEquals( i + 1, optimizer.getLastValue() ); assertEquals( increment + 1, optimizer.getLastSourceValue() ); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/idgen/enhanced/forcedtable/HiLoForcedTableSequenceTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/idgen/enhanced/sequence/PooledSequenceTest.java
Method name: void testNormalBoundary() Method name: void testNormalBoundary()
Number of AST nodes: 7 Number of AST nodes: 7
1
for ( int i = 0; i < increment; i++ ) {
1
entities[i] = new Entity( "" + ( i + 1 ) );
2
			entities[i] = new Entity( "" + ( i + 1 ) );
2
			s.save( entities[i] );
3
			s.save( entities[i] );
3
			long expectedId = i + 1;
4
			
4
			assertEquals( expectedId, entities[i].getId().longValue() );
5
assertEquals( 2, generator.getDatabaseStructure().getTimesAccessed() ); // initialization calls seq twice
5
			assertEquals( 1, generator.getOptimizer().getLastSourceValue() );
6
			assertEquals( increment + 1, optimizer.getLastSourceValue() ); // initialization calls seq twice
6
			assertEquals( i + 1, optimizer.getLastValue() );
7
			assertEquals( i + 1, optimizer.getLastValue() );
7
			assertEquals( increment + 1, optimizer.getHiValue() );
8
			assertEquals( increment + 1, optimizer.getLastSourceValue() );
9
		}
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 comparisons43
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                      
    11
    entities[i] = new Entity("" + (i + 1));
    Preondition Violations
    Unmatched statement entities[i]=new Entity("" + (i + 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    entities[i] = new Entity("" + (i + 1));
    11
    entities[i] = new Entity("" + (i + 1));
    11
    entities[i] = new Entity("" + (i + 1));
    Preondition Violations
    Unmatched statement entities[i]=new Entity("" + (i + 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    12
    s.save(entities[i]);
    12
    s.save(entities[i]);
    12
    s.save(entities[i]);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.idgen.enhanced.forcedtable.Entity[]org.hibernate.test.idgen.enhanced.sequence.Entity[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.idgen.enhanced.forcedtable.Entity[] of variable entities does not match with type org.hibernate.test.idgen.enhanced.sequence.Entity[] of variable entities
    • Make classes org.hibernate.test.idgen.enhanced.forcedtable.Entity[] and org.hibernate.test.idgen.enhanced.sequence.Entity[] extend a common superclass
    12
    s.save(entities[i]);
    13
    long expectedId = i + 1;
                                                        
    14
    assertEquals(expectedId, entities[i].getId().longValue());
                                                                                                                              
    15
    assertEquals(1, generator.getOptimizer().getLastSourceValue());
    15
    assertEquals(1, generator.getOptimizer().getLastSourceValue());
    13
    assertEquals(2, generator.getDatabaseStructure().getTimesAccessed());
    Differences
    Expression1Expression2Difference
    12LITERAL_VALUE_MISMATCH
    getLastSourceValuegetTimesAccessedMETHOD_INVOCATION_NAME_MISMATCH
    longintVARIABLE_TYPE_MISMATCH
    getOptimizergetDatabaseStructureMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.id.enhanced.Optimizerorg.hibernate.id.enhanced.DatabaseStructureVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type long of variable generator.getOptimizer().getLastSourceValue() does not match with type int of variable generator.getDatabaseStructure().getTimesAccessed()
    Type org.hibernate.id.enhanced.Optimizer of variable generator.getOptimizer() does not match with type org.hibernate.id.enhanced.DatabaseStructure of variable generator.getDatabaseStructure()
    • Make classes org.hibernate.id.enhanced.Optimizer and org.hibernate.id.enhanced.DatabaseStructure extend a common superclass
    13
    assertEquals(2, generator.getDatabaseStructure().getTimesAccessed());
    16
    assertEquals(i + 1, optimizer.getLastValue());
    16
    assertEquals(i + 1, optimizer.getLastValue());
    14
    assertEquals(increment + 1, optimizer.getLastSourceValue());
    Differences
    Expression1Expression2Difference
    iincrementVARIABLE_NAME_MISMATCH
    getLastValuegetLastSourceValueMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.id.enhanced.OptimizerFactory.HiLoOptimizerorg.hibernate.id.enhanced.OptimizerFactory.PooledOptimizerSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression optimizer cannot be unified with expression optimizer , because common superclass org.hibernate.id.enhanced.OptimizerFactory.OptimizerSupport does not declare member(s) public long getLastValue()
    14
    assertEquals(increment + 1, optimizer.getLastSourceValue());
    17
    assertEquals(increment + 1, optimizer.getHiValue());
    17
    assertEquals(increment + 1, optimizer.getHiValue());
    15
    assertEquals(i + 1, optimizer.getLastValue());
    Differences
    Expression1Expression2Difference
    incrementiVARIABLE_NAME_MISMATCH
    getHiValuegetLastValueMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.id.enhanced.OptimizerFactory.HiLoOptimizerorg.hibernate.id.enhanced.OptimizerFactory.PooledOptimizerSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression optimizer cannot be unified with expression optimizer , because common superclass org.hibernate.id.enhanced.OptimizerFactory.OptimizerSupport does not declare member(s) public long getHiValue() , public long getLastValue()
    15
    assertEquals(i + 1, optimizer.getLastValue());
                                                                                                                                  
    16
    assertEquals(increment + 1, optimizer.getLastSourceValue());
    Precondition Violations (7)
    Row Violation
    1Unmatched statement entities[i]=new Entity("" + (i + 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement entities[i]=new Entity("" + (i + 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type org.hibernate.test.idgen.enhanced.forcedtable.Entity[] of variable entities does not match with type org.hibernate.test.idgen.enhanced.sequence.Entity[] of variable entities
    4Type long of variable generator.getOptimizer().getLastSourceValue() does not match with type int of variable generator.getDatabaseStructure().getTimesAccessed()
    5Type org.hibernate.id.enhanced.Optimizer of variable generator.getOptimizer() does not match with type org.hibernate.id.enhanced.DatabaseStructure of variable generator.getDatabaseStructure()
    6Expression optimizer cannot be unified with expression optimizer , because common superclass org.hibernate.id.enhanced.OptimizerFactory.OptimizerSupport does not declare member(s) public long getLastValue()
    7Expression optimizer cannot be unified with expression optimizer , because common superclass org.hibernate.id.enhanced.OptimizerFactory.OptimizerSupport does not declare member(s) public long getHiValue() , public long getLastValue()