if ( ! supportsUnboundedLobLocatorMaterialization() ) { return; } // Note: unbounded mutation of the underlying lob data is completely // unsupported; most databases would not allow such a construct anyway. // Thus here we are only testing materialization... byte[] original = buildRecursively( BLOB_SIZE, true ); Session s = openSession(); s.beginTransaction(); LobHolder entity = new LobHolder(); entity.setBlobLocator( Hibernate.createBlob( original ) ); s.save( entity ); s.getTransaction().commit(); s.close(); // load the entity with the clob locator, and close the session/transaction; // at that point it is unbounded... s = openSession(); s.beginTransaction(); entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); s.getTransaction().commit(); s.close(); assertEquals( BLOB_SIZE, entity.getBlobLocator().length() ); assertEquals( original, extractData( entity.getBlobLocator() ) ); s = openSession(); s.beginTransaction(); s.delete( entity ); s.getTransaction().commit(); s.close();
if ( ! supportsUnboundedLobLocatorMaterialization() ) { return; } // Note: unbounded mutation of the underlying lob data is completely // unsupported; most databases would not allow such a construct anyway. // Thus here we are only testing materialization... String original = buildRecursively( CLOB_SIZE, 'x' ); Session s = openSession(); s.beginTransaction(); LobHolder entity = new LobHolder(); entity.setClobLocator( Hibernate.createClob( original ) ); s.save( entity ); s.getTransaction().commit(); s.close(); // load the entity with the clob locator, and close the session/transaction; // at that point it is unbounded... s = openSession(); s.beginTransaction(); entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); s.getTransaction().commit(); s.close(); assertEquals( CLOB_SIZE, entity.getClobLocator().length() ); assertEquals( original, extractData( entity.getClobLocator() ) ); s = openSession(); s.beginTransaction(); 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 testUnboundedBlobLocatorAccess() Method name: void testUnboundedClobLocatorAccess()
Number of AST nodes: 22 Number of AST nodes: 22
1
if ( ! supportsUnboundedLobLocatorMaterialization() ) {
1
if ( ! supportsUnboundedLobLocatorMaterialization() ) {
2
			return;
2
			return;
3
		}
3
		}
4
		// Note: unbounded mutation of the underlying lob data is completely
4
		// Note: unbounded mutation of the underlying lob data is completely
5
		// unsupported; most databases would not allow such a construct anyway.
5
		// unsupported; most databases would not allow such a construct anyway.
6
		// Thus here we are only testing materialization...
6
		// Thus here we are only testing materialization...
7
		byte[] original = buildRecursively( BLOB_SIZE, true );
7
		String original = buildRecursively( CLOB_SIZE, 'x' );
8
		Session s = openSession();
8
		Session s = openSession();
9
		s.beginTransaction();
9
		s.beginTransaction();
10
		LobHolder entity = new LobHolder();
10
		LobHolder entity = new LobHolder();
11
		entity.setBlobLocator( Hibernate.createBlob( original ) );
11
		entity.setClobLocator( Hibernate.createClob( original ) );
12
		s.save( entity );
12
		s.save( entity );
13
		s.getTransaction().commit();
13
		s.getTransaction().commit();
14
		s.close();
14
		s.close();
15
		// load the entity with the clob locator, and close the session/transaction;
15
		// load the entity with the clob locator, and close the session/transaction;
16
		// at that point it is unbounded...
16
		// at that point it is unbounded...
17
		s = openSession();
17
		s = openSession();
18
		s.beginTransaction();
18
		s.beginTransaction();
19
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
19
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
20
		s.getTransaction().commit();
20
		s.getTransaction().commit();
21
		s.close();
21
		s.close();
22
		assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
22
		assertEquals( CLOB_SIZE, entity.getClobLocator().length() );
23
		assertEquals( original, extractData( entity.getBlobLocator() ) );
23
		assertEquals( original, extractData( entity.getClobLocator() ) );
24
		s = openSession();
24
		s = openSession();
25
		s.beginTransaction();
25
		s.beginTransaction();
26
		s.delete( entity );
26
		s.delete( entity );
27
		s.getTransaction().commit();
27
		s.getTransaction().commit();
28
		s.close();
28
		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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons88
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements20
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)47.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (!supportsUnboundedLobLocatorMaterialization())
    1
    if (!supportsUnboundedLobLocatorMaterialization())
    2
    return;
    2
    return;
                                                                                                          
    3
    String original = buildRecursively(CLOB_SIZE, 'x');
    3
    byte[] original = buildRecursively(BLOB_SIZE, true);
                                                                                                            
    4
    Session s = openSession();
    4
    Session s = openSession();
    5
    s.beginTransaction();
    5
    s.beginTransaction();
    6
    LobHolder entity = new LobHolder();
    6
    LobHolder entity = new LobHolder();
    7
    entity.setBlobLocator(Hibernate.createBlob(original));
    7
    entity.setBlobLocator(Hibernate.createBlob(original));
    7
    entity.setClobLocator(Hibernate.createClob(original));
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    createBlobcreateClobMETHOD_INVOCATION_NAME_MISMATCH
    java.sql.Blobjava.sql.ClobVARIABLE_TYPE_MISMATCH
    setBlobLocatorsetClobLocatorMETHOD_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 Hibernate.createBlob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Hibernate.createClob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.sql.Blob of variable Hibernate.createBlob(original) does not match with type java.sql.Clob of variable Hibernate.createClob(original)
    • Make classes java.sql.Blob and java.sql.Clob extend a common superclass
    Expression entity.setBlobLocator(Hibernate.createBlob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.setClobLocator(Hibernate.createClob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.setBlobLocator(Hibernate.createBlob(original)) is a void method call, and thus it cannot be parameterized
    Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized
    7
    entity.setClobLocator(Hibernate.createClob(original));
    8
    s.save(entity);
    8
    s.save(entity);
    9
    s.getTransaction().commit();
    9
    s.getTransaction().commit();
    10
    s.close();
    10
    s.close();
    11
    s = openSession();
    11
    s = openSession();
    12
    s.beginTransaction();
    12
    s.beginTransaction();
    13
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    13
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    15
    s.close();
    15
    s.close();
                                                                                                                              
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    Preondition Violations
    Unmatched statement assertEquals(CLOB_SIZE,entity.getClobLocator().length()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    16
    assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
    16
    assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
    Preondition Violations
    Unmatched statement assertEquals(BLOB_SIZE,entity.getBlobLocator().length()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                              
    17
    assertEquals(original, extractData(entity.getBlobLocator()));
    17
    assertEquals(original, extractData(entity.getBlobLocator()));
    17
    assertEquals(original, extractData(entity.getClobLocator()));
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    getBlobLocatorgetClobLocatorMETHOD_INVOCATION_NAME_MISMATCH
    java.sql.Blobjava.sql.ClobVARIABLE_TYPE_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.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator()
    • Make classes java.sql.Blob and java.sql.Clob extend a common superclass
    Expression extractData(entity.getBlobLocator()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method extractData
    Expression extractData(entity.getClobLocator()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method extractData
    Type byte[] of variable extractData(entity.getBlobLocator()) does not match with type java.lang.String of variable extractData(entity.getClobLocator())
    • Make classes byte[] and java.lang.String extend a common superclass
    17
    assertEquals(original, extractData(entity.getClobLocator()));
    18
    s = openSession();
    18
    s = openSession();
    19
    s.beginTransaction();
    19
    s.beginTransaction();
    20
    s.delete(entity);
    20
    s.delete(entity);
    21
    s.getTransaction().commit();
    21
    s.getTransaction().commit();
    22
    s.close();
    22
    s.close();
    Precondition Violations (17)
    Row Violation
    1Type byte[] of variable original does not match with type java.lang.String of variable original
    2Expression Hibernate.createBlob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression Hibernate.createClob(original) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type java.sql.Blob of variable Hibernate.createBlob(original) does not match with type java.sql.Clob of variable Hibernate.createClob(original)
    5Expression entity.setBlobLocator(Hibernate.createBlob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression entity.setClobLocator(Hibernate.createClob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression entity.setBlobLocator(Hibernate.createBlob(original)) is a void method call, and thus it cannot be parameterized
    8Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized
    9Unmatched statement assertEquals(CLOB_SIZE,entity.getClobLocator().length()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement assertEquals(BLOB_SIZE,entity.getBlobLocator().length()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Type byte[] of variable original does not match with type java.lang.String of variable original
    12Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator()
    15Expression extractData(entity.getBlobLocator()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression extractData(entity.getClobLocator()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Type byte[] of variable extractData(entity.getBlobLocator()) does not match with type java.lang.String of variable extractData(entity.getClobLocator())