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(); Glarch g1 = new Glarch(); Glarch g2 = new Glarch(); g1.setNext(g2); g2.setNext(g1); s.save(g1); s.save(g2); s.flush(); s.connection().commit(); s.close(); s = openSession(); List l = s.find("from Glarch g where g.next is not null"); s.delete( l.get(0) ); s.delete( l.get(1) ); 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 testNoForeignKeyViolations()
Number of AST nodes: 19 Number of AST nodes: 17
1
Session session = openSession();
1
Session s = openSession();
2
		Transaction trans = session.beginTransaction();
2
		Glarch g1 = new Glarch();
3
		ServerImpl server = new ServerImpl();
3
		Glarch g2 = new Glarch();
4
		session.save( server );
4
		g1.setNext(g2);
5
		AddressImpl address = new AddressImpl();
5
		g2.setNext(g1);
6
		server.setAddress( address );
6
		s.save(g1);
7
		address.setServer( server );
7
		s.save(g2);
8
		session.flush();
8
		s.flush();
9
		session.createQuery( "from Server s join fetch s.address" ).list();
9
		s
10
		trans.commit();
10
.connection().commit();
11
		session.close();
11
		s.close();
12
		assertNotNull( server.getId() );
13
		assertNotNull( address.getId() );
14
		session
15
 = openSession();
12
		s = openSession();
16
		trans = session.beginTransaction();
13
		List l = s.find("from Glarch g where g.next is not null");
17
		session.delete( address );
14
		s.delete( l.get(0) );
18
		session.delete( server );
15
		s.delete( l.get(1) );
19
		trans
16
		s.flush();
20
.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 session = openSession();
    1
    Session session = openSession();
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    1
    Session s = openSession();
                                                        
    2
    Glarch g1 = new Glarch();
    2
    Transaction trans = session.beginTransaction();
    2
    Transaction trans = session.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction trans=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                    
                                                        
    3
    Glarch g2 = new Glarch();
    3
    ServerImpl server = new ServerImpl();
                                                                                
                                        
    4
    g1.setNext(g2);
    Preondition Violations
    Unmatched statement g1.setNext(g2); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    g1.setNext(g2);
                                        
    5
    g2.setNext(g1);
    Preondition Violations
    Unmatched statement g2.setNext(g1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    g2.setNext(g1);
    4
    session.save(server);
    4
    session.save(server);
    6
    s.save(g1);
    Differences
    Expression1Expression2Difference
    serverg1VARIABLE_NAME_MISMATCH
    org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImplorg.hibernate.test.legacy.GlarchVARIABLE_TYPE_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl of variable server does not match with type org.hibernate.test.legacy.Glarch of variable g1
    • Make classes org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl and org.hibernate.test.legacy.Glarch extend a common superclass
    6
    s.save(g1);
    5
    AddressImpl address = new AddressImpl();
                                                                                      
    6
    server.setAddress(address);
    6
    server.setAddress(address);
    Preondition Violations
    Unmatched statement server.setAddress(address); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                
                                
    7
    s.save(g2);
    Preondition Violations
    Unmatched statement s.save(g2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    s.save(g2);
    7
    address.setServer(server);
    7
    address.setServer(server);
    Preondition Violations
    Unmatched statement address.setServer(server); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                              
    8
    session.flush();
    8
    session.flush();
    8
    s.flush();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    8
    s.flush();
                                                          
    9
    s.connection().commit();
    Preondition Violations
    Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    s.connection().commit();
    9
    session.createQuery("from Server s join fetch s.address").list();
    9
    session.createQuery("from Server s join fetch s.address").list();
    Preondition Violations
    Unmatched statement session.createQuery("from Server s join fetch s.address").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                            
    10
    trans.commit();
    10
    trans.commit();
    Preondition Violations
    Unmatched statement trans.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                          
    11
    session.close();
    11
    session.close();
    10
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    10
    s.close();
    12
    assertNotNull(server.getId());
                                                                        
    13
    assertNotNull(address.getId());
                                                                          
    14
    session = openSession();
    14
    session = openSession();
    11
    s = openSession();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    11
    s = openSession();
                                                                                                                            
    12
    List l = s.find("from Glarch g where g.next is not null");
    Preondition Violations
    Unmatched statement List l=s.find("from Glarch g where g.next is not null"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    List l = s.find("from Glarch g where g.next is not null");
                                                  
    13
    s.delete(l.get(0));
    Preondition Violations
    Unmatched statement s.delete(l.get(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    s.delete(l.get(0));
                                                  
    14
    s.delete(l.get(1));
    Preondition Violations
    Unmatched statement s.delete(l.get(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    s.delete(l.get(1));
    15
    trans = session.beginTransaction();
    15
    trans = session.beginTransaction();
    Preondition Violations
    Unmatched statement trans=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                              
    16
    session.delete(address);
    16
    session.delete(address);
    15
    s.flush();
    Differences
    Expression1Expression2Difference
    deleteflushMETHOD_INVOCATION_NAME_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    session.delete(address)s.flush()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression session.delete(address) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression session.delete(address) 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 session.delete(address) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression session.delete(address) 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();
                                                            
    16
    s.connection().commit();
    Preondition Violations
    Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    s.connection().commit();
    17
    session.delete(server);
    17
    session.delete(server);
    Preondition Violations
    Unmatched statement session.delete(server); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                          
    18
    trans.commit();
    18
    trans.commit();
    Preondition Violations
    Unmatched statement trans.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                          
    19
    session.close();
    19
    session.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    17
    s.close();
    Precondition Violations (26)
    Row Violation
    1Unmatched statement Transaction trans=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement g1.setNext(g2); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement g2.setNext(g1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Type org.hibernate.test.abstractembeddedcomponents.propertyref.ServerImpl of variable server does not match with type org.hibernate.test.legacy.Glarch of variable g1
    5Unmatched statement server.setAddress(address); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement s.save(g2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement address.setServer(server); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement session.createQuery("from Server s join fetch s.address").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement trans.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11Unmatched statement List l=s.find("from Glarch g where g.next is not null"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement s.delete(l.get(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement s.delete(l.get(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement trans=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Expression session.delete(address) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression session.delete(address) is a void method call, and thus it cannot be parameterized
    18Expression s.flush() is a void method call, and thus it cannot be parameterized
    19Expression session.delete(address) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression session.delete(address) is a void method call, and thus it cannot be parameterized
    22Expression s.flush() is a void method call, and thus it cannot be parameterized
    23Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement session.delete(server); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Unmatched statement trans.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    26Clone fragment #1 returns variable session with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session