Session s = openSession(); s.beginTransaction(); Mammal tiger = new Mammal(); tiger.setDescription( "Tiger" ); s.persist( tiger ); Mammal mother = new Mammal(); mother.setDescription( "Tiger's mother" ); mother.setBodyWeight( 4.0f ); mother.addOffspring( tiger ); s.persist( mother ); Zoo zoo = new Zoo(); zoo.setName( "Austin Zoo" ); zoo.setMammals( new HashMap() ); zoo.getMammals().put( "tiger", tiger ); s.persist( zoo ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); List results = s.createQuery( "from Zoo zoo where zoo.mammals['tiger'].mother.bodyWeight > 3.0f" ).list(); assertEquals( 1, results.size() ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.delete( tiger ); s.delete( mother ); s.delete( zoo ); s.getTransaction().commit(); s.close();
Session s = openSession(); Foo foo = new Foo(); s.save(foo); foo.setString("dirty"); s.flush(); s.connection().commit(); s.close(); s = openSession(); Foo foo2 = new Foo(); s.load( foo2, foo.getKey() ); // There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15 assertTrue( "create-update", foo.equalsFoo(foo2) ); //System.out.println( s.print(foo2) ); s.delete(foo2); s.flush(); s.connection().commit(); s.close(); s = openSession(); foo = new Foo(); s.save(foo, "assignedid"); foo.setString("dirty"); s.flush(); s.connection().commit(); s.close(); s = openSession(); s.load(foo2, "assignedid"); // There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15 assertTrue( "create-update", foo.equalsFoo(foo2) ); //System.out.println( s.print(foo2) ); s.delete(foo2); s.flush(); s.connection().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/hql/ASTParserLoadingTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Method name: void testSuperclassPropertyReferenceAfterCollectionIndexedAccess() Method name: void testCreateUpdate()
Number of AST nodes: 30 Number of AST nodes: 29
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		
3
		Mammal tiger = new Mammal();
3
Foo foo = new 
4
		tiger.setDescription( "Tiger" );
5
		s.persist( tiger );
6
		Mammal mother = new Mammal();
7
		mother.setDescription( "Tiger's mother" );
8
		mother.setBodyWeight( 4.0f );
9
		mother.addOffspring( tiger );
10
		s.persist( mother 
4
Foo();
5
		s.save(foo);
6
		foo.setString("dirty");
7
		s.flush();
8
		s.connection().commit();
9
		s.close();
11
);
10
		s = openSession();
12
		Zoo zoo = new Zoo();
11
		Foo foo2 = new Foo();
13
		zoo.setName( "Austin Zoo" );
12
		
14
		zoo.setMammals( new HashMap() );
15
		zoo.getMammals().put( "tiger", tiger );
16
		s.persist( zoo );
17
		s.getTransa
13
s.load( foo2, foo.getKey() );
14
		// There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15
15
		assertTrue( "create-update", foo.equalsFoo(foo2) );
16
		//System.out.println( s.print(foo2) );
17
		s.delete(foo2);
18
		s.flush();
18
ction().commit();
19
		s.connection().commit();
19
		s.close();
20
		s.close();
20
		s = openSession();
21
		s = openSession();
21
		s.beginTransaction();
22
		
22
		List results = s.createQuery( "from Zoo zoo where zoo.mammals['tiger'].mother.bodyWeight > 3.0f" ).list();
23
		assertEquals( 1, results.size() );
24
		s.getTransa
23
foo = new Foo();
24
		s.save(foo, "assignedid");
25
		foo.setString("dirty");
26
		s.flush();
25
ction().commit();
27
		s.connection().commit();
26
		s.close();
28
		s.close();
27
		s = openSession();
29
		s = openSession();
28
		s.beginTransaction();
30
		s.
29
		s.delete( tiger );
30
		s.delete( mother );
31
		s.delete( zoo );
32
		s.getTransa
31
load(foo2, "assignedid");
32
		// There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15
33
		assertTrue( "create-update", foo.equalsFoo(foo2) );
34
		//System.out.println( s.print(foo2) );
35
		s.delete(foo2);
36
		s.flush();
33
ction().commit();
37
		s.connection().commit();
34
		s.close();
38
		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 comparisons714
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment19
    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
    Session s = openSession();
    1
    Session s = openSession();
                                                          
                                              
    2
    Foo foo = new Foo();
    2
    s.beginTransaction();
                                                    
                                  
    3
    s.save(foo);
    3
    Mammal tiger = new Mammal();
                                                              
    4
    tiger.setDescription("Tiger");
                                                                      
                              
    5
    s.flush();
    5
    s.persist(tiger);
                                            
    6
    Mammal mother = new Mammal();
                                                                
                              
    7
    s.close();
    7
    mother.setDescription("Tiger's mother");
                                                                                          
                                          
    8
    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
    8
    s = openSession();
    8
    mother.setBodyWeight(4.0f);
                                                                
                                                
    9
    Foo foo2 = new Foo();
    9
    mother.addOffspring(tiger);
                                                                
                                                                
    10
    s.load(foo2, foo.getKey());
    10
    s.persist(mother);
    10
    s.persist(mother);
    11
    assertTrue("create-update", foo.equalsFoo(foo2));
    Differences
    Expression1Expression2Difference
    persistassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.persist(mother)assertTrue("create-update",foo.equalsFoo(foo2))ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertTrue("create-update",foo.equalsFoo(foo2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.persist(mother) is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create-update",foo.equalsFoo(foo2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.persist(mother) is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    11
    assertTrue("create-update", foo.equalsFoo(foo2));
    11
    Zoo zoo = new Zoo();
                                                
    12
    zoo.setName("Austin Zoo");
                                                                
                                
    13
    s.flush();
    13
    zoo.setMammals(new HashMap());
                                                                        
    14
    zoo.getMammals().put("tiger", tiger);
                                                                                    
                                            
    16
    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
    16
    s = openSession();
                                        
    17
    foo = new Foo();
    Preondition Violations
    Unmatched statement foo=new Foo(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    foo = new Foo();
                                                              
    18
    s.save(foo, "assignedid");
                                                          
    19
    foo.setString("dirty");
    Preondition Violations
    Unmatched statement foo.setString("dirty"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19
    foo.setString("dirty");
                                
    20
    s.flush();
                                            
    23
    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
    23
    s = openSession();
                                                                
    24
    s.load(foo2, "assignedid");
    15
    s.persist(zoo);
    15
    s.persist(zoo);
    25
    assertTrue("create-update", foo.equalsFoo(foo2));
    Differences
    Expression1Expression2Difference
    persistassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.persist(zoo)assertTrue("create-update",foo.equalsFoo(foo2))ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.persist(zoo) is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    Expression s.persist(zoo) is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    25
    assertTrue("create-update", foo.equalsFoo(foo2));
    16
    s.getTransaction().commit();
    16
    s.getTransaction().commit();
    14
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    14
    s.connection().commit();
    17
    s.close();
    17
    s.close();
    15
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    15
    s.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
    s.beginTransaction();
                                                      
    20
    List results = s.createQuery("from Zoo zoo where zoo.mammals['tiger'].mother.bodyWeight > 3.0f").list();
                                                                                                                                                                                                                        
    21
    assertEquals(1, results.size());
    21
    assertEquals(1, results.size());
    4
    foo.setString("dirty");
    Differences
    Expression1Expression2Difference
    assertEqualssetStringMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(1,results.size())foo.setString("dirty")ARGUMENT_NUMBER_MISMATCH
    fooMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals(1,results.size()) is a void method call, and thus it cannot be parameterized
    Expression foo.setString("dirty") is a void method call, and thus it cannot be parameterized
    Expression assertEquals(1,results.size()) is a void method call, and thus it cannot be parameterized
    Expression foo.setString("dirty") is a void method call, and thus it cannot be parameterized
    4
    foo.setString("dirty");
    22
    s.getTransaction().commit();
    22
    s.getTransaction().commit();
    21
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    21
    s.connection().commit();
    23
    s.close();
    23
    s.close();
    22
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    22
    s.close();
    24
    s = openSession();
    24
    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
                                            
    25
    s.beginTransaction();
                                                      
    26
    s.delete(tiger);
    26
    s.delete(tiger);
    26
    s.delete(foo2);
    Differences
    Expression1Expression2Difference
    tigerfoo2VARIABLE_NAME_MISMATCH
    org.hibernate.test.hql.Mammalorg.hibernate.test.legacy.FooVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.hql.Mammal of variable tiger does not match with type org.hibernate.test.legacy.Foo of variable foo2
    • Make classes org.hibernate.test.hql.Mammal and org.hibernate.test.legacy.Foo extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    26
    s.delete(foo2);
    27
    s.delete(mother);
    27
    s.delete(mother);
    12
    s.delete(foo2);
    Differences
    Expression1Expression2Difference
    motherfoo2VARIABLE_NAME_MISMATCH
    org.hibernate.test.hql.Mammalorg.hibernate.test.legacy.FooVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.hql.Mammal of variable mother does not match with type org.hibernate.test.legacy.Foo of variable foo2
    • Make classes org.hibernate.test.hql.Mammal and org.hibernate.test.legacy.Foo extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    12
    s.delete(foo2);
    28
    s.delete(zoo);
                                        
    29
    s.getTransaction().commit();
    29
    s.getTransaction().commit();
    6
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    6
    s.connection().commit();
                                
    27
    s.flush();
                                                            
    28
    s.connection().commit();
    30
    s.close();
    30
    s.close();
    29
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    29
    s.close();
    Precondition Violations (34)
    Row Violation
    1Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression assertTrue("create-update",foo.equalsFoo(foo2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression s.persist(mother) is a void method call, and thus it cannot be parameterized
    4Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    5Expression assertTrue("create-update",foo.equalsFoo(foo2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression s.persist(mother) is a void method call, and thus it cannot be parameterized
    7Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    8Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement foo=new Foo(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement foo.setString("dirty"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Expression s.persist(zoo) is a void method call, and thus it cannot be parameterized
    13Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    14Expression s.persist(zoo) is a void method call, and thus it cannot be parameterized
    15Expression assertTrue("create-update",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    16Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    17Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    18Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    19Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Expression assertEquals(1,results.size()) is a void method call, and thus it cannot be parameterized
    21Expression foo.setString("dirty") is a void method call, and thus it cannot be parameterized
    22Expression assertEquals(1,results.size()) is a void method call, and thus it cannot be parameterized
    23Expression foo.setString("dirty") is a void method call, and thus it cannot be parameterized
    24Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    25Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    26Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    27Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28Type org.hibernate.test.hql.Mammal of variable tiger does not match with type org.hibernate.test.legacy.Foo of variable foo2
    29Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    30Type org.hibernate.test.hql.Mammal of variable mother does not match with type org.hibernate.test.legacy.Foo of variable foo2
    31Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    32Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    33Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    34Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s