Session s = openSession(); Baz baz = new Baz(); List list = new ArrayList(); baz.setBazez(list); list.add( new Baz() ); s.save(baz); s.flush(); list.add( new Baz() ); s.flush(); list.add( 0, new Baz() ); s.flush(); s.delete( list.remove(1) ); s.flush(); s.delete(baz); s.flush(); s.connection().commit(); s.close();
Session s = openSession(); Category c = new Category(); c.setName("NAME"); Assignable assn = new Assignable(); assn.setId("i.d."); List l = new ArrayList(); l.add(c); assn.setCategories(l); c.setAssignable(assn); s.save(assn); s.flush(); s.connection().commit(); s.close(); s = openSession(); s.delete(assn); 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/legacy/FooBarTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java
Method name: void testBagOneToMany() Method name: void testMixNativeAssigned()
Number of AST nodes: 17 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		Baz baz = new Baz();
2
		
3
		List list = new ArrayList();
4
		baz.setBazez(list
3
Category c = new Category();
4
		c.setName("NAME");
5
		Assignable assn = new Assignable();
5
);
6
		assn.setId("i.d.");
6
		list.add( new Baz() );
7
		List
7
		s.save(baz);
8
		s.flush();
9
		list.add( new Baz() );
10
		s.flush();
11
		list.add( 0, new Baz() );
12
		s.flush();
13
		s.delete( list.remove(1) );
14
		s.flush
8
 l = new ArrayList();
9
		l.add(c);
10
		assn.setCategories(l);
11
		c.setAssignable(assn);
12
		s.save(assn);
13
		s.flush();
14
		s.connection().commit();
15
		s.close();
15
();
16
		s = openSession();
16
		s.delete(baz);
17
		s.delete(assn);
17
		s.flush();
18
		s.flush();
18
		s.connection().commit();
19
		s.connection().commit();
19
		s.close();
20
		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 comparisons229
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment10
    Number of unmapped statements in the second code fragment11
    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
    Category c = new Category();
    2
    Baz baz = new Baz();
                                              
                                              
    3
    c.setName("NAME");
    Preondition Violations
    Unmatched statement c.setName("NAME"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    c.setName("NAME");
                                                                            
    4
    Assignable assn = new Assignable();
                                                
    5
    assn.setId("i.d.");
    Preondition Violations
    Unmatched statement assn.setId("i.d."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    assn.setId("i.d.");
    3
    List list = new ArrayList();
    3
    List list = new ArrayList();
    6
    List l = new ArrayList();
    Differences
    Expression1Expression2Difference
    listlVARIABLE_NAME_MISMATCH
    6
    List l = new ArrayList();
    4
    baz.setBazez(list);
    4
    baz.setBazez(list);
    Preondition Violations
    Unmatched statement baz.setBazez(list); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                
    5
    list.add(new Baz());
    5
    list.add(new Baz());
    Preondition Violations
    Unmatched statement list.add(new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
                            
    7
    l.add(c);
    Preondition Violations
    Unmatched statement l.add(c); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    l.add(c);
    6
    s.save(baz);
    6
    s.save(baz);
    10
    s.save(assn);
    Differences
    Expression1Expression2Difference
    bazassnVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.AssignableVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Assignable of variable assn
    • Make classes org.hibernate.test.legacy.Baz and org.hibernate.test.legacy.Assignable extend a common superclass
    10
    s.save(assn);
    7
    s.flush();
    7
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                              
                                                      
    8
    assn.setCategories(l);
    Preondition Violations
    Unmatched statement assn.setCategories(l); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    assn.setCategories(l);
    8
    list.add(new Baz());
    8
    list.add(new Baz());
    Preondition Violations
    Unmatched statement list.add(new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
                                                      
    9
    c.setAssignable(assn);
    Preondition Violations
    Unmatched statement c.setAssignable(assn); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9
    c.setAssignable(assn);
    9
    s.flush();
    9
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                              
    10
    list.add(0, new Baz());
    10
    list.add(0, new Baz());
    Preondition Violations
    Unmatched statement list.add(0,new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                        
    11
    s.flush();
    11
    s.flush();
    12
    s.delete(list.remove(1));
    12
    s.delete(list.remove(1));
    Preondition Violations
    Unmatched statement s.delete(list.remove(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                              
    13
    s.flush();
    13
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    14
    s.delete(baz);
    14
    s.delete(baz);
    Preondition Violations
    Unmatched statement s.delete(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                        
    15
    s.flush();
    16
    s.flush();
    16
    s.connection().commit();
    12
    s.connection().commit();
    17
    s.close();
    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();
                                          
    15
    s.delete(assn);
                                                            
    17
    s.connection().commit();
                                
    18
    s.close();
    Precondition Violations (17)
    Row Violation
    1Unmatched statement c.setName("NAME"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement assn.setId("i.d."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement baz.setBazez(list); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement list.add(new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement l.add(c); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Assignable of variable assn
    7Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement assn.setCategories(l); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement list.add(new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement c.setAssignable(assn); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement list.add(0,new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement s.delete(list.remove(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement s.delete(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Clone fragment #1 returns variables list, s , while Clone fragment #2 returns variables l, s