Session session = openSession(); Transaction trans = session.beginTransaction(); ServerImpl server = new ServerImpl(); session.save( server ); AddressImpl address = new AddressImpl(); server.setAddress( address ); address.setServer( server ); session.flush(); session.createQuery( "from Server s join fetch s.address" ).list(); trans.commit(); session.close(); assertNotNull( server.getId() ); assertNotNull( address.getId() ); session = openSession(); trans = session.beginTransaction(); session.delete( address ); session.delete( server ); trans.commit(); session.close();
Session s = openSession(); Baz baz = new Baz(); Foo foo = new Foo(); List bag = new ArrayList(); bag.add(foo); baz.setIdFooBag(bag); baz.setFoo(foo); s.save(baz); s.flush(); s.connection().commit(); s.close(); s = openSession(); baz = (Baz) s.load( Baz.class, baz.getCode() ); s.delete(baz); 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/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Method name: void testPropertiesRefCascades() Method name: void testForeignKeys()
Number of AST nodes: 19 Number of AST nodes: 17
1
Session session = openSession();
1
Session s = openSession();
2
		Transaction trans = session.beginTransaction();
2
		Baz baz = new Baz();
3
		ServerImpl server = new ServerImpl();
3
		Foo foo = new Foo();
4
		session.save( server );
4
		List bag = new ArrayList();
5
		AddressImpl address = new AddressImpl();
5
		bag.add(foo);
6
		server.setAddress( address );
6
		baz.setIdFooBag(bag);
7
		address.setServer( server 
7
		baz.setFoo(foo);
8
);
8
		s.save(baz);
9
		session.flush();
9
		s.flush();
10
		session.createQuery( "from Server s join fetch s.address" ).list();
10
		s
11
		trans.commit();
11
.connection().commit();
12
		session.close();
12
		s.close();
13
		assertNotNull( server.getId() );
14
		assertNotNull( address.getId() );
15
		session
16
 = openSession();
13
		s = openSession();
17
		trans = session.beginTransaction();
14
		baz = (Baz) s.load( Baz.class, baz.getCode() );
18
		session.delete( address );
15
		s.delete(baz);
19
		session.delete( server );
16
		s.flush();
20
		trans.commit();
17
		s.connection().commit();
21
		session.close();
18
		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 comparisons323
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment12
    Number of unmapped statements in the second code fragment10
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                          
    1
    Session s = openSession();
    1
    Session session = openSession();
                                                                      
                                              
    2
    Baz baz = new Baz();
    2
    Transaction trans = session.beginTransaction();
                                                                                                    
                                              
    3
    Foo foo = new Foo();
    3
    ServerImpl server = new ServerImpl();
                                                                                
                                                            
    4
    List bag = new ArrayList();
                                    
    5
    bag.add(foo);
                                                    
    6
    baz.setIdFooBag(bag);
                                          
    7
    baz.setFoo(foo);
    4
    session.save(server);
    4
    session.save(server);
    8
    s.save(baz);
    Differences
    Expression1Expression2Difference
    serverbazVARIABLE_NAME_MISMATCH
    org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImplorg.hibernate.test.legacy.BazVARIABLE_TYPE_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl of variable server does not match with type org.hibernate.test.legacy.Baz of variable baz
    • Make classes org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl and org.hibernate.test.legacy.Baz extend a common superclass
    Type org.hibernate.Session of variable session 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
    8
    s.save(baz);
    5
    AddressImpl address = new AddressImpl();
                                                                                      
    6
    server.setAddress(address);
                                                                
    7
    address.setServer(server);
                                                              
    8
    session.flush();
    8
    session.flush();
    9
    s.flush();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable session 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
    9
    s.flush();
    9
    session.createQuery("from Server s join fetch s.address").list();
                                                                                                                                            
    10
    trans.commit();
                                          
    11
    session.close();
    11
    session.close();
    11
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable session 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
    11
    s.close();
    12
    assertNotNull(server.getId());
    12
    assertNotNull(server.getId());
    10
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    assertNotNullcommitMETHOD_INVOCATION_NAME_MISMATCH
    assertNotNull(server.getId())s.connection().commit()ARGUMENT_NUMBER_MISMATCH
    s.connection()MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertNotNull(server.getId()) is a void method call, and thus it cannot be parameterized
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(server.getId()) is a void method call, and thus it cannot be parameterized
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    10
    s.connection().commit();
                                            
    12
    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
    s = openSession();
                                                                                              
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
    Preondition Violations
    Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
    13
    assertNotNull(address.getId());
    13
    assertNotNull(address.getId());
    15
    s.flush();
    Differences
    Expression1Expression2Difference
    assertNotNullflushMETHOD_INVOCATION_NAME_MISMATCH
    assertNotNull(address.getId())s.flush()ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertNotNull(address.getId()) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(address.getId()) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    15
    s.flush();
    14
    session = openSession();
    14
    session = openSession();
    Preondition Violations
    Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                        
    15
    trans = session.beginTransaction();
                                                                              
    16
    session.delete(address);
                                                            
    17
    session.delete(server);
    17
    session.delete(server);
    14
    s.delete(baz);
    Differences
    Expression1Expression2Difference
    serverbazVARIABLE_NAME_MISMATCH
    org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImplorg.hibernate.test.legacy.BazVARIABLE_TYPE_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl of variable server does not match with type org.hibernate.test.legacy.Baz of variable baz
    • Make classes org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl and org.hibernate.test.legacy.Baz extend a common superclass
    Type org.hibernate.Session of variable session 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.delete(baz);
                                                            
    16
    s.connection().commit();
    18
    trans.commit();
                                          
    19
    session.close();
    19
    session.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable session 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
    17
    s.close();
    Precondition Violations (18)
    Row Violation
    1Type org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl of variable server does not match with type org.hibernate.test.legacy.Baz of variable baz
    2Type org.hibernate.Session of variable session does not match with type org.hibernate.classic.Session of variable s
    3Type org.hibernate.Session of variable session does not match with type org.hibernate.classic.Session of variable s
    4Type org.hibernate.Session of variable session does not match with type org.hibernate.classic.Session of variable s
    5Expression assertNotNull(server.getId()) is a void method call, and thus it cannot be parameterized
    6Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    7Expression assertNotNull(server.getId()) is a void method call, and thus it cannot be parameterized
    8Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    9Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Expression assertNotNull(address.getId()) is a void method call, and thus it cannot be parameterized
    12Expression s.flush() is a void method call, and thus it cannot be parameterized
    13Expression assertNotNull(address.getId()) is a void method call, and thus it cannot be parameterized
    14Expression s.flush() is a void method call, and thus it cannot be parameterized
    15Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Type org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl of variable server does not match with type org.hibernate.test.legacy.Baz of variable baz
    17Type org.hibernate.Session of variable session does not match with type org.hibernate.classic.Session of variable s
    18Type org.hibernate.Session of variable session does not match with type org.hibernate.classic.Session of variable s