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();
Session s = openSession(); Transaction t = s.beginTransaction(); Location mel = new Location("Earth"); s.save(mel); Human gavin = new Human(); gavin.setIdentity("gavin"); gavin.setSex('M'); gavin.setLocation(mel); mel.addBeing(gavin); gavin.getInfo().put("foo", "bar"); gavin.getInfo().put("x", "y"); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); gavin = (Human) s.createCriteria(Human.class).uniqueResult(); assertEquals( gavin.getInfo().size(), 2 ); s.delete(gavin); s.delete( gavin.getLocation() ); t.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/stateless/StatelessSessionTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java
Method name: void testRefresh() Method name: void testUnionSubclassCollection()
Number of AST nodes: 22 Number of AST nodes: 21
1
StatelessSession ss = getSessions().openStatelessSession();
1
Session s = openSession();
2
		Transaction tx = ss.beginTransaction();
2
		Transaction t = s.beginTransaction();
3
		Paper paper = new Paper();
3
		
4
		paper.setColor( "whtie" );
5
		ss.insert( paper );
6
		tx.commit();
7
		ss.close(
4
Location mel = new Location("Earth");
5
		s.save(mel);
6
		
7
		Human gavin = new Human();
8
		gavin.setIdentity("gavin");
8
);
9
		gavin.setSex('M');
9
		ss = getSessions().openStatelessSession();
10
		gavin.setLocation(mel);
10
		tx = ss.beginTransaction();
11
		
11
		Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() );
12
		p2.setColor( "White" );
13
		ss.update( p2 
12
mel.addBeing(gavin);
13
		
14
		gavin.getInfo().put("foo", "bar");
14
);
15
		gavin.getInfo().put("x", "y");
15
		
16
		
16
tx.commit();
17
		t.commit();
17
		ss.close();
18
		s.close();
18
		ss = getSessions().openStatelessSession();
19
		s = openSession();
19
		tx = ss.beginTransaction();
20
		t = s.beginTransaction();
20
		assertEquals( "whtie", paper.getColor() );
21
		
21
		ss.refresh( paper );
22
gavin = (Human) s.createCriteria(Human.class).uniqueResult();
22
		assertEquals( "White", paper.getColor() );
23
		assertEquals( 
23
		ss.delete( paper
24
gavin.getInfo().size(), 2 );
25
		s.delete(gavin);
24
 );
26
		s.delete( gavin.getLocation() );
25
		tx.commit();
27
		t.commit();
26
		ss.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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons375
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment17
    Number of unmapped statements in the second code fragment16
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                          
    1
    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
    1
    Session s = openSession();
    1
    StatelessSession ss = getSessions().openStatelessSession();
                                                                                                                            
    2
    Transaction tx = ss.beginTransaction();
    2
    Transaction tx = ss.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    Differences
    Expression1Expression2Difference
    txtVARIABLE_NAME_MISMATCH
    sssVARIABLE_NAME_MISMATCH
    org.hibernate.StatelessSessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.StatelessSession and org.hibernate.Session extend a common superclass
    2
    Transaction t = s.beginTransaction();
                                                                                
    3
    Location mel = new Location("Earth");
    Preondition Violations
    Unmatched statement Location mel=new Location("Earth"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    Location mel = new Location("Earth");
    3
    Paper paper = new Paper();
                                                          
                                  
    4
    s.save(mel);
    4
    paper.setColor("whtie");
    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
                                                          
                                                          
    5
    Human gavin = new Human();
    5
    ss.insert(paper);
                                            
                                                                
    6
    gavin.setIdentity("gavin");
    Preondition Violations
    Unmatched statement gavin.setIdentity("gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6
    gavin.setIdentity("gavin");
                                              
    7
    gavin.setSex('M');
    Preondition Violations
    Unmatched statement gavin.setSex('M'); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7
    gavin.setSex('M');
                                                        
    8
    gavin.setLocation(mel);
    Preondition Violations
    Unmatched statement gavin.setLocation(mel); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8
    gavin.setLocation(mel);
                                                  
    9
    mel.addBeing(gavin);
    Preondition Violations
    Unmatched statement mel.addBeing(gavin); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9
    mel.addBeing(gavin);
                                                                              
    10
    gavin.getInfo().put("foo", "bar");
    6
    tx.commit();
    6
    tx.commit();
    12
    t.commit();
    Differences
    Expression1Expression2Difference
    txtVARIABLE_NAME_MISMATCH
    12
    t.commit();
    7
    ss.close();
                                
    8
    ss = getSessions().openStatelessSession();
    8
    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
                                                                                          
    9
    tx = ss.beginTransaction();
    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
                                                            
    10
    Paper p2 = (Paper)ss.get(Paper.class, paper.getId());
    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
                                                                                                                
                                                                      
    11
    gavin.getInfo().put("x", "y");
    11
    p2.setColor("White");
    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
                                                      
    12
    ss.update(p2);
                                        
                                
    13
    s.close();
                                            
    14
    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
    14
    s = openSession();
    13
    tx.commit();
    13
    tx.commit();
    20
    t.commit();
    Differences
    Expression1Expression2Difference
    txtVARIABLE_NAME_MISMATCH
    20
    t.commit();
    14
    ss.close();
                                  
    15
    ss = getSessions().openStatelessSession();
                                                                                            
    16
    tx = ss.beginTransaction();
    16
    tx = ss.beginTransaction();
    15
    t = s.beginTransaction();
    Differences
    Expression1Expression2Difference
    txtVARIABLE_NAME_MISMATCH
    sssVARIABLE_NAME_MISMATCH
    org.hibernate.StatelessSessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.StatelessSession and org.hibernate.Session extend a common superclass
    15
    t = s.beginTransaction();
                                                                                                                                
    16
    gavin = (Human)s.createCriteria(Human.class).uniqueResult();
                                                                                          
    17
    assertEquals(gavin.getInfo().size(), 2);
    17
    assertEquals("whtie", paper.getColor());
                                                                                          
    18
    ss.refresh(paper);
                                                
    19
    assertEquals("White", paper.getColor());
                                                                                          
    20
    ss.delete(paper);
    20
    ss.delete(paper);
    18
    s.delete(gavin);
    Differences
    Expression1Expression2Difference
    papergavinVARIABLE_NAME_MISMATCH
    org.hibernate.test.stateless.Paperorg.hibernate.test.unionsubclass.HumanVARIABLE_TYPE_MISMATCH
    sssVARIABLE_NAME_MISMATCH
    org.hibernate.StatelessSessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.stateless.Paper of variable paper does not match with type org.hibernate.test.unionsubclass.Human of variable gavin
    • Make classes org.hibernate.test.stateless.Paper and org.hibernate.test.unionsubclass.Human extend a common superclass
    Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.StatelessSession and org.hibernate.Session extend a common superclass
    18
    s.delete(gavin);
                                                                        
    19
    s.delete(gavin.getLocation());
                                
    21
    s.close();
    21
    tx.commit();
    21
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    22
    ss.close();
                                  
    Precondition Violations (18)
    Row Violation
    1Unmatched statement Session s=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    3Unmatched statement Location mel=new Location("Earth"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement paper.setColor("whtie"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement gavin.setIdentity("gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement gavin.setSex('M'); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement gavin.setLocation(mel); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement mel.addBeing(gavin); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9Unmatched statement ss=getSessions().openStatelessSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched 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
    12Unmatched statement p2.setColor("White"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    15Type org.hibernate.test.stateless.Paper of variable paper does not match with type org.hibernate.test.unionsubclass.Human of variable gavin
    16Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    17Unmatched statement tx.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Clone fragment #1 returns variables tx , while Clone fragment #2 returns variables