byte[] original = buildRecursively( BLOB_SIZE, true ); byte[] changed = buildRecursively( BLOB_SIZE, false ); Session s = openSession(); s.beginTransaction(); LobHolder entity = new LobHolder(); entity.setMaterializedBlob( original ); s.save( entity ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); assertEquals( BLOB_SIZE, entity.getMaterializedBlob().length ); assertEquals( original, entity.getMaterializedBlob() ); entity.setMaterializedBlob( changed ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); assertEquals( BLOB_SIZE, entity.getMaterializedBlob().length ); assertEquals( changed, entity.getMaterializedBlob() ); s.delete( entity ); s.getTransaction().commit(); s.close();
String original = buildRecursively( CLOB_SIZE, 'x' ); String changed = buildRecursively( CLOB_SIZE, 'y' ); Session s = openSession(); s.beginTransaction(); LobHolder entity = new LobHolder(); entity.setMaterializedClob( original ); s.save( entity ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); assertEquals( CLOB_SIZE, entity.getMaterializedClob().length() ); assertEquals( original, entity.getMaterializedClob() ); entity.setMaterializedClob( changed ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); assertEquals( CLOB_SIZE, entity.getMaterializedClob().length() ); assertEquals( changed, entity.getMaterializedClob() ); s.delete( entity ); s.getTransaction().commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lob/BlobTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lob/ClobTest.java
Method name: void testBoundedMaterializedBlobAccess() Method name: void testBoundedMaterializedClobAccess()
Number of AST nodes: 25 Number of AST nodes: 25
1
byte[] original = buildRecursively( BLOB_SIZE, true );
1
String original = buildRecursively( CLOB_SIZE, 'x' );
2
		byte[] changed = buildRecursively( BLOB_SIZE, false );
2
		String changed = buildRecursively( CLOB_SIZE, 'y' );
3
		Session s = openSession();
3
		Session s = openSession();
4
		s.beginTransaction();
4
		s.beginTransaction();
5
		LobHolder entity = new LobHolder();
5
		LobHolder entity = new LobHolder();
6
		entity.setMaterializedBlob( original );
6
		entity.setMaterializedClob( original );
7
		s.save( entity );
7
		s.save( entity );
8
		s.getTransaction().commit();
8
		s.getTransaction().commit();
9
		s.close();
9
		s.close();
10
		s = openSession();
10
		s = openSession();
11
		s.beginTransaction();
11
		s.beginTransaction();
12
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
12
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
13
		assertEquals( BLOB_SIZE, entity.getMaterializedBlob().length );
13
		assertEquals( CLOB_SIZE, entity.getMaterializedClob().length() );
14
		assertEquals( original, entity.getMaterializedBlob() );
14
		assertEquals( original, entity.getMaterializedClob() );
15
		entity.setMaterializedBlob( changed );
15
		entity.setMaterializedClob( changed );
16
		s.getTransaction().commit();
16
		s.getTransaction().commit();
17
		s.close();
17
		s.close();
18
		s = openSession();
18
		s = openSession();
19
		s.beginTransaction();
19
		s.beginTransaction();
20
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
20
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
21
		assertEquals( BLOB_SIZE, entity.getMaterializedBlob().length );
21
		assertEquals( CLOB_SIZE, entity.getMaterializedClob().length() );
22
		assertEquals( changed, entity.getMaterializedBlob() );
22
		assertEquals( changed, entity.getMaterializedClob() );
23
		s.delete( entity );
23
		s.delete( entity );
24
		s.getTransaction().commit();
24
		s.getTransaction().commit();
25
		s.close();
25
		s.close();
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 comparisons125
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements23
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                          
    1
    String original = buildRecursively(CLOB_SIZE, 'x');
    1
    byte[] original = buildRecursively(BLOB_SIZE, true);
                                                                                                            
                                                                                                        
    2
    String changed = buildRecursively(CLOB_SIZE, 'y');
    2
    byte[] changed = buildRecursively(BLOB_SIZE, false);
                                                                                                            
    3
    Session s = openSession();
    3
    Session s = openSession();
    4
    s.beginTransaction();
    4
    s.beginTransaction();
    5
    LobHolder entity = new LobHolder();
    5
    LobHolder entity = new LobHolder();
    6
    entity.setMaterializedBlob(original);
    6
    entity.setMaterializedBlob(original);
    6
    entity.setMaterializedClob(original);
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    setMaterializedBlobsetMaterializedClobMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Type byte[] of variable original does not match with type java.lang.String of variable original
    • Make classes byte[] and java.lang.String extend a common superclass
    Expression entity.setMaterializedBlob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.setMaterializedClob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.setMaterializedBlob(original) is a void method call, and thus it cannot be parameterized
    Expression entity.setMaterializedClob(original) is a void method call, and thus it cannot be parameterized
    6
    entity.setMaterializedClob(original);
    7
    s.save(entity);
    7
    s.save(entity);
    8
    s.getTransaction().commit();
    8
    s.getTransaction().commit();
    9
    s.close();
    9
    s.close();
    10
    s = openSession();
    10
    s = openSession();
    11
    s.beginTransaction();
    11
    s.beginTransaction();
    12
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    12
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    13
    assertEquals(BLOB_SIZE, entity.getMaterializedBlob().length);
    13
    assertEquals(BLOB_SIZE, entity.getMaterializedBlob().length);
    13
    assertEquals(CLOB_SIZE, entity.getMaterializedClob().length());
    Differences
    Expression1Expression2Difference
    BLOB_SIZECLOB_SIZEVARIABLE_NAME_MISMATCH
    entity.getMaterializedBlob().lengthentity.getMaterializedClob().length()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression entity.getMaterializedBlob().length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.getMaterializedClob().length() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    assertEquals(CLOB_SIZE, entity.getMaterializedClob().length());
    14
    assertEquals(original, entity.getMaterializedBlob());
    14
    assertEquals(original, entity.getMaterializedBlob());
    14
    assertEquals(original, entity.getMaterializedClob());
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    getMaterializedBlobgetMaterializedClobMETHOD_INVOCATION_NAME_MISMATCH
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable original does not match with type java.lang.String of variable original
    • Make classes byte[] and java.lang.String extend a common superclass
    Expression entity.getMaterializedBlob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.getMaterializedClob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type byte[] of variable entity.getMaterializedBlob() does not match with type java.lang.String of variable entity.getMaterializedClob()
    • Make classes byte[] and java.lang.String extend a common superclass
    14
    assertEquals(original, entity.getMaterializedClob());
    15
    entity.setMaterializedBlob(changed);
    15
    entity.setMaterializedBlob(changed);
    15
    entity.setMaterializedClob(changed);
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    setMaterializedBlobsetMaterializedClobMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Type byte[] of variable changed does not match with type java.lang.String of variable changed
    • Make classes byte[] and java.lang.String extend a common superclass
    Expression entity.setMaterializedBlob(changed) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.setMaterializedClob(changed) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.setMaterializedBlob(changed) is a void method call, and thus it cannot be parameterized
    Expression entity.setMaterializedClob(changed) is a void method call, and thus it cannot be parameterized
    15
    entity.setMaterializedClob(changed);
    16
    s.getTransaction().commit();
    16
    s.getTransaction().commit();
    17
    s.close();
    17
    s.close();
    18
    s = openSession();
    18
    s = openSession();
    19
    s.beginTransaction();
    19
    s.beginTransaction();
    20
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    20
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    21
    assertEquals(BLOB_SIZE, entity.getMaterializedBlob().length);
    21
    assertEquals(BLOB_SIZE, entity.getMaterializedBlob().length);
    21
    assertEquals(CLOB_SIZE, entity.getMaterializedClob().length());
    Differences
    Expression1Expression2Difference
    BLOB_SIZECLOB_SIZEVARIABLE_NAME_MISMATCH
    entity.getMaterializedBlob().lengthentity.getMaterializedClob().length()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression entity.getMaterializedBlob().length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.getMaterializedClob().length() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21
    assertEquals(CLOB_SIZE, entity.getMaterializedClob().length());
    22
    assertEquals(changed, entity.getMaterializedBlob());
    22
    assertEquals(changed, entity.getMaterializedBlob());
    22
    assertEquals(changed, entity.getMaterializedClob());
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    getMaterializedBlobgetMaterializedClobMETHOD_INVOCATION_NAME_MISMATCH
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable changed does not match with type java.lang.String of variable changed
    • Make classes byte[] and java.lang.String extend a common superclass
    Expression entity.getMaterializedBlob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.getMaterializedClob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type byte[] of variable entity.getMaterializedBlob() does not match with type java.lang.String of variable entity.getMaterializedClob()
    • Make classes byte[] and java.lang.String extend a common superclass
    22
    assertEquals(changed, entity.getMaterializedClob());
    23
    s.delete(entity);
    23
    s.delete(entity);
    24
    s.getTransaction().commit();
    24
    s.getTransaction().commit();
    25
    s.close();
    25
    s.close();
    Precondition Violations (22)
    Row Violation
    1Type byte[] of variable original does not match with type java.lang.String of variable original
    2Expression entity.setMaterializedBlob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression entity.setMaterializedClob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression entity.setMaterializedBlob(original) is a void method call, and thus it cannot be parameterized
    5Expression entity.setMaterializedClob(original) is a void method call, and thus it cannot be parameterized
    6Expression entity.getMaterializedBlob().length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression entity.getMaterializedClob().length() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Type byte[] of variable original does not match with type java.lang.String of variable original
    9Expression entity.getMaterializedBlob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression entity.getMaterializedClob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type byte[] of variable entity.getMaterializedBlob() does not match with type java.lang.String of variable entity.getMaterializedClob()
    12Type byte[] of variable changed does not match with type java.lang.String of variable changed
    13Expression entity.setMaterializedBlob(changed) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression entity.setMaterializedClob(changed) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression entity.setMaterializedBlob(changed) is a void method call, and thus it cannot be parameterized
    16Expression entity.setMaterializedClob(changed) is a void method call, and thus it cannot be parameterized
    17Expression entity.getMaterializedBlob().length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression entity.getMaterializedClob().length() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Type byte[] of variable changed does not match with type java.lang.String of variable changed
    20Expression entity.getMaterializedBlob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression entity.getMaterializedClob() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Type byte[] of variable entity.getMaterializedBlob() does not match with type java.lang.String of variable entity.getMaterializedClob()