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 comparisons433
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment14
    Number of unmapped statements in the second code fragment13
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                          
    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");
    3
    Paper paper = new Paper();
                                                          
                                  
    4
    s.save(mel);
    4
    paper.setColor("whtie");
                                                          
                                                          
    5
    Human gavin = new Human();
    5
    ss.insert(paper);
                                            
    6
    tx.commit();
    6
    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
                                  
    7
    ss.close();
                                
                                                        
    8
    gavin.setLocation(mel);
    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());
                                                                                                                
    11
    p2.setColor("White");
                                                      
    12
    ss.update(p2);
                                        
    13
    tx.commit();
    13
    tx.commit();
    12
    t.commit();
    Differences
    Expression1Expression2Difference
    txtVARIABLE_NAME_MISMATCH
    12
    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();
    17
    assertEquals("whtie", paper.getColor());
    17
    assertEquals("whtie", paper.getColor());
    7
    gavin.setSex('M');
    Differences
    Expression1Expression2Difference
    assertEqualssetSexMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals("whtie",paper.getColor())gavin.setSex('M')ARGUMENT_NUMBER_MISMATCH
    gavinMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized
    Expression gavin.setSex('M') 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 gavin.setSex('M') is a void method call, and thus it cannot be parameterized
    7
    gavin.setSex('M');
    18
    ss.refresh(paper);
    18
    ss.refresh(paper);
    17
    assertEquals(gavin.getInfo().size(), 2);
    Differences
    Expression1Expression2Difference
    refreshassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    ss.refresh(paper)assertEquals(gavin.getInfo().size(),2)ARGUMENT_NUMBER_MISMATCH
    ssMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression ss.refresh(paper) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(gavin.getInfo().size(),2) is a void method call, and thus it cannot be parameterized
    Expression ss.refresh(paper) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(gavin.getInfo().size(),2) is a void method call, and thus it cannot be parameterized
    17
    assertEquals(gavin.getInfo().size(), 2);
    19
    assertEquals("White", paper.getColor());
    19
    assertEquals("White", paper.getColor());
    6
    gavin.setIdentity("gavin");
    Differences
    Expression1Expression2Difference
    assertEqualssetIdentityMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals("White",paper.getColor())gavin.setIdentity("gavin")ARGUMENT_NUMBER_MISMATCH
    gavinMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals("White",paper.getColor()) is a void method call, and thus it cannot be parameterized
    Expression gavin.setIdentity("gavin") is a void method call, and thus it cannot be parameterized
    Expression assertEquals("White",paper.getColor()) is a void method call, and thus it cannot be parameterized
    Expression gavin.setIdentity("gavin") is a void method call, and thus it cannot be parameterized
    6
    gavin.setIdentity("gavin");
                                                  
    9
    mel.addBeing(gavin);
                                                                              
    10
    gavin.getInfo().put("foo", "bar");
                                                                      
    11
    gavin.getInfo().put("x", "y");
                                
    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();
                                                                                                                                
    16
    gavin = (Human)s.createCriteria(Human.class).uniqueResult();
    Preondition Violations
    Unmatched statement gavin=(Human)s.createCriteria(Human.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    gavin = (Human)s.createCriteria(Human.class).uniqueResult();
    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
    tx.commit();
    21
    tx.commit();
    20
    t.commit();
    Differences
    Expression1Expression2Difference
    txtVARIABLE_NAME_MISMATCH
    20
    t.commit();
                                
    21
    s.close();
    22
    ss.close();
                                  
    Precondition Violations (22)
    Row Violation
    1Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    2Unmatched statement tx.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement ss=getSessions().openStatelessSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    6Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized
    7Expression gavin.setSex('M') is a void method call, and thus it cannot be parameterized
    8Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized
    9Expression gavin.setSex('M') is a void method call, and thus it cannot be parameterized
    10Expression ss.refresh(paper) is a void method call, and thus it cannot be parameterized
    11Expression assertEquals(gavin.getInfo().size(),2) is a void method call, and thus it cannot be parameterized
    12Expression ss.refresh(paper) is a void method call, and thus it cannot be parameterized
    13Expression assertEquals(gavin.getInfo().size(),2) is a void method call, and thus it cannot be parameterized
    14Expression assertEquals("White",paper.getColor()) is a void method call, and thus it cannot be parameterized
    15Expression gavin.setIdentity("gavin") is a void method call, and thus it cannot be parameterized
    16Expression assertEquals("White",paper.getColor()) is a void method call, and thus it cannot be parameterized
    17Expression gavin.setIdentity("gavin") is a void method call, and thus it cannot be parameterized
    18Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement gavin=(Human)s.createCriteria(Human.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Type org.hibernate.test.stateless.Paper of variable paper does not match with type org.hibernate.test.unionsubclass.Human of variable gavin
    21Type org.hibernate.StatelessSession of variable ss does not match with type org.hibernate.Session of variable s
    22Clone fragment #1 returns variables tx , while Clone fragment #2 returns variables