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();
StatelessSession ss = getSessions().openStatelessSession(); Transaction tx = ss.beginTransaction(); Paper paper = new Paper(); paper.setColor( "whtie" ); ss.insert( paper ); tx.commit(); ss.close(); ss = getSessions().openStatelessSession(); tx = ss.beginTransaction(); Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() ); p2.setColor( "White" ); ss.update( p2 ); tx.commit(); ss.close(); ss = getSessions().openStatelessSession(); tx = ss.beginTransaction(); assertEquals( "whtie", paper.getColor() ); ss.refresh( paper ); assertEquals( "White", paper.getColor() ); ss.delete( paper ); tx.commit(); ss.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/ClobTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java
Method name: void testUnboundedClobLocatorAccess() Method name: void testRefresh()
Number of AST nodes: 22 Number of AST nodes: 22
1
if ( ! supportsUnboundedLobLocatorMaterialization() ) {
2
			return;
3
		}
4
		// Note: unbounded mutation of the underlying lob data is completely
5
		// unsupported; most databases would not allow such a construct anyway.
6
		// Thus here we are only testing materialization...
7
		String original = buildRecursively( CLOB_SIZE, 'x' );
8
		Session s = openSession();
9
		
1
StatelessSession ss = getSessions().openStatelessSession();
10
s.beginTransaction();
2
		Transaction tx = ss.beginTransaction();
11
		LobHolder entity = new LobHolder();
3
		Paper paper = new Paper();
12
		entity.setClobLocator( Hibernate.createClob( original ) );
4
		paper.setColor( "whtie" );
13
		s.save( entity );
5
		ss.insert( paper );
14
		s.getTransaction().commit();
6
		tx.commit();
15
		s.close();
7
		ss.close();
16
		// load the entity with the clob locator, and close the session/transaction;
17
		// at that point it is unbounded...
18
		s = open
19
Session();
8
		ss = getSessions().openStatelessSession();
20
		s.beginTransaction();
9
		tx = ss.beginTransaction();
21
		entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
10
		Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() );
22
		s.getTransaction()
11
		p2.setColor( "White" );
12
		ss.update( p2 );
23
.commit();
13
		tx.commit();
24
		s.close();
14
		ss.close();
25

26
		assertEquals( CLOB_SIZE, entity.getClobLocator().length() 
15
		ss = getSessions().openStatelessSession();
27
);
16
		tx = ss.beginTransaction();
28
		assertEquals( original, extractData( entity.getClobLocator() ) );
17
		assertEquals( "whtie", paper.getColor() );
29

30
		s = openSession();
18
		ss.refresh( paper );
31
		s.beginTransaction();
19
		assertEquals( "White", paper.getColor() );
32
		s.delete( entity );
20
		ss.delete( paper );
33
		s.getTransaction().commit();
21
		tx.commit();
34
		s.close();
22
		ss.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 comparisons440
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment13
    Number of unmapped statements in the second code fragment15
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                            
    1
    StatelessSession ss = getSessions().openStatelessSession();
                                                                                    
    2
    Transaction tx = ss.beginTransaction();
                                                          
    3
    Paper paper = new Paper();
    3
    String original = buildRecursively(CLOB_SIZE, 'x');
                                                                                                          
                                                          
    4
    paper.setColor("whtie");
    4
    Session s = openSession();
                                                          
                                            
    5
    ss.insert(paper);
    5
    s.beginTransaction();
                                                    
    6
    LobHolder entity = new LobHolder();
                                                                            
    7
    entity.setClobLocator(Hibernate.createClob(original));
    7
    entity.setClobLocator(Hibernate.createClob(original));
    17
    assertEquals("whtie", paper.getColor());
    Differences
    Expression1Expression2Difference
    setClobLocatorassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    entity.setClobLocator(Hibernate.createClob(original))assertEquals("whtie",paper.getColor())ARGUMENT_NUMBER_MISMATCH
    entityMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals("whtie",paper.getColor()) 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
    Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized
    17
    assertEquals("whtie", paper.getColor());
    8
    s.save(entity);
                                        
    9
    s.getTransaction().commit();
    9
    s.getTransaction().commit();
    6
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    6
    tx.commit();
                                
    7
    ss.close();
                                                                                          
    8
    ss = getSessions().openStatelessSession();
                                                            
    9
    tx = ss.beginTransaction();
    Preondition Violations
    Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    tx = ss.beginTransaction();
                                                                                                                
    10
    Paper p2 = (Paper)ss.get(Paper.class, paper.getId());
    10
    s.close();
                                
                                                      
    11
    p2.setColor("White");
    11
    s = openSession();
    11
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
                                        
    12
    ss.update(p2);
    12
    s.beginTransaction();
                                                      
    13
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    13
    entity = (LobHolder)s.get(LobHolder.class, entity.getId());
    Preondition Violations
    Unmatched statement entity=(LobHolder)s.get(LobHolder.class,entity.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                            
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    13
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    13
    tx.commit();
    15
    s.close();
                                
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    14
    ss.close();
    Differences
    Expression1Expression2Difference
    assertEqualscloseMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(CLOB_SIZE,entity.getClobLocator().length())ss.close()ARGUMENT_NUMBER_MISMATCH
    ssMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized
    Expression ss.close() is a void method call, and thus it cannot be parameterized
    Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized
    Expression ss.close() is a void method call, and thus it cannot be parameterized
    14
    ss.close();
                                                                                            
    15
    ss = getSessions().openStatelessSession();
    Preondition Violations
    Unmatched statement ss=getSessions().openStatelessSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    ss = getSessions().openStatelessSession();
                                                              
    16
    tx = ss.beginTransaction();
    Preondition Violations
    Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    tx = ss.beginTransaction();
                                                
    18
    ss.refresh(paper);
    17
    assertEquals(original, extractData(entity.getClobLocator()));
    17
    assertEquals(original, extractData(entity.getClobLocator()));
    22
    ss.close();
    Differences
    Expression1Expression2Difference
    assertEqualscloseMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(original,extractData(entity.getClobLocator()))ss.close()ARGUMENT_NUMBER_MISMATCH
    ssMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals(original,extractData(entity.getClobLocator())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(original,extractData(entity.getClobLocator())) is a void method call, and thus it cannot be parameterized
    Expression ss.close() is a void method call, and thus it cannot be parameterized
    Expression assertEquals(original,extractData(entity.getClobLocator())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(original,extractData(entity.getClobLocator())) is a void method call, and thus it cannot be parameterized
    Expression ss.close() is a void method call, and thus it cannot be parameterized
    22
    ss.close();
    18
    s = openSession();
    18
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
                                                                                          
    19
    assertEquals("White", paper.getColor());
    19
    s.beginTransaction();
                                                      
    20
    s.delete(entity);
    20
    s.delete(entity);
    20
    ss.delete(paper);
    Differences
    Expression1Expression2Difference
    entitypaperVARIABLE_NAME_MISMATCH
    org.hibernate.test.lob.LobHolderorg.hibernate.test.stateless.PaperVARIABLE_TYPE_MISMATCH
    sssVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.StatelessSessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.lob.LobHolder of variable entity does not match with type org.hibernate.test.stateless.Paper of variable paper
    • Make classes org.hibernate.test.lob.LobHolder and org.hibernate.test.stateless.Paper extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.StatelessSession of variable ss
    • Make classes org.hibernate.Session and org.hibernate.StatelessSession extend a common superclass
    20
    ss.delete(paper);
    21
    s.getTransaction().commit();
    21
    s.getTransaction().commit();
    21
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    21
    tx.commit();
    22
    s.close();
                                
    Precondition Violations (24)
    Row Violation
    1Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized
    2Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized
    3Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized
    4Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized
    5Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement entity=(LobHolder)s.get(LobHolder.class,entity.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized
    10Expression ss.close() is a void method call, and thus it cannot be parameterized
    11Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized
    13Expression ss.close() is a void method call, and thus it cannot be parameterized
    14Unmatched statement ss=getSessions().openStatelessSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Expression assertEquals(original,extractData(entity.getClobLocator())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression assertEquals(original,extractData(entity.getClobLocator())) is a void method call, and thus it cannot be parameterized
    18Expression ss.close() is a void method call, and thus it cannot be parameterized
    19Expression assertEquals(original,extractData(entity.getClobLocator())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression assertEquals(original,extractData(entity.getClobLocator())) is a void method call, and thus it cannot be parameterized
    21Expression ss.close() is a void method call, and thus it cannot be parameterized
    22Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Type org.hibernate.test.lob.LobHolder of variable entity does not match with type org.hibernate.test.stateless.Paper of variable paper
    24Type org.hibernate.Session of variable s does not match with type org.hibernate.StatelessSession of variable ss