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 statements4
    Number of unmapped statements in the first code fragment16
    Number of unmapped statements in the second code fragment18
    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();
    Preondition Violations
    Unmatched statement Transaction tx=ss.beginTransaction(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    Transaction tx = ss.beginTransaction();
                                                          
    3
    Paper paper = new Paper();
    3
    String original = buildRecursively(CLOB_SIZE, 'x');
                                                                                                          
                                                          
    4
    paper.setColor("whtie");
    Preondition Violations
    Unmatched statement paper.setColor("whtie"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    paper.setColor("whtie");
    4
    Session s = openSession();
    4
    Session s = openSession();
    Preondition Violations
    Unmatched statement Session s=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                          
                                            
    5
    ss.insert(paper);
    5
    s.beginTransaction();
                                                    
    6
    LobHolder entity = new LobHolder();
                                                                            
                                
    7
    ss.close();
    7
    entity.setClobLocator(Hibernate.createClob(original));
    7
    entity.setClobLocator(Hibernate.createClob(original));
    Preondition Violations
    Unmatched statement entity.setClobLocator(Hibernate.createClob(original)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                      
                                                                                          
    8
    ss = getSessions().openStatelessSession();
    8
    s.save(entity);
                                        
                                                            
    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());
    Preondition Violations
    Unmatched statement Paper p2=(Paper)ss.get(Paper.class,paper.getId()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10
    Paper p2 = (Paper)ss.get(Paper.class, paper.getId());
    9
    s.getTransaction().commit();
    9
    s.getTransaction().commit();
    21
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21
    tx.commit();
    10
    s.close();
                                
                                                      
    11
    p2.setColor("White");
    Preondition Violations
    Unmatched statement p2.setColor("White"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    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());
                                                                                                                            
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    13
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    tx.commit();
                                  
    14
    ss.close();
                                                                                            
    15
    ss = getSessions().openStatelessSession();
    15
    s.close();
                                
                                                              
    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();
    16
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
                                                                                                                              
                                                                                          
    17
    assertEquals("whtie", paper.getColor());
    17
    assertEquals(original, extractData(entity.getClobLocator()));
                                                                                                                                    
                                                
    18
    ss.refresh(paper);
    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();
    6
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    tx.commit();
                                  
    22
    ss.close();
    22
    s.close();
                                
    Precondition Violations (18)
    Row Violation
    1Unmatched statement Transaction tx=ss.beginTransaction(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement paper.setColor("whtie"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement Session s=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement entity.setClobLocator(Hibernate.createClob(original)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    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 Paper p2=(Paper)ss.get(Paper.class,paper.getId()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Unmatched statement p2.setColor("White"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Type org.hibernate.test.lob.LobHolder of variable entity does not match with type org.hibernate.test.stateless.Paper of variable paper
    16Type org.hibernate.Session of variable s does not match with type org.hibernate.StatelessSession of variable ss
    17Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted