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 statements21
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)4.9
    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
    setBlobLocatorsetClobLocatorMETHOD_INVOCATION_NAME_MISMATCH
    createBlobcreateClobMETHOD_INVOCATION_NAME_MISMATCH
    java.sql.Blobjava.sql.ClobVARIABLE_TYPE_MISMATCH
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    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
    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
    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
    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(BLOB_SIZE, entity.getBlobLocator().length());
    16
    assertEquals(BLOB_SIZE, entity.getBlobLocator().length());
    17
    assertEquals(original, extractData(entity.getClobLocator()));
    Differences
    Expression1Expression2Difference
    BLOB_SIZEoriginalVARIABLE_NAME_MISMATCH
    intjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable BLOB_SIZE does not match with type java.lang.String of variable original
    17
    assertEquals(original, extractData(entity.getClobLocator()));
    17
    assertEquals(original, extractData(entity.getBlobLocator()));
    17
    assertEquals(original, extractData(entity.getBlobLocator()));
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    Differences
    Expression1Expression2Difference
    originalCLOB_SIZEVARIABLE_NAME_MISMATCH
    byte[]intVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable original does not match with type int of variable CLOB_SIZE
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    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 (8)
    Row Violation
    1Expression entity.setBlobLocator(Hibernate.createBlob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression entity.setClobLocator(Hibernate.createClob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression entity.setBlobLocator(Hibernate.createBlob(original)) is a void method call, and thus it cannot be parameterized
    4Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized
    5Type java.sql.Blob of variable Hibernate.createBlob(original) does not match with type java.sql.Clob of variable Hibernate.createClob(original)
    6Type byte[] of variable original does not match with type java.lang.String of variable original
    7Type int of variable BLOB_SIZE does not match with type java.lang.String of variable original
    8Type byte[] of variable original does not match with type int of variable CLOB_SIZE