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();
Session s = openSession(); W w1 = new W(); W w2 = new W(); Z z = new Z(); z.setW(w1); s.save(z); s.flush(); z.setW(w2); s.flush(); s.connection().commit(); s.close(); s = openSession(); s.update(z); s.flush(); s.delete(z); s.delete("from W"); 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/MasterDetailTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java
Method name: void testMixNativeAssigned() Method name: void testNoUpdateManyToOne()
Number of AST nodes: 18 Number of AST nodes: 19
1
Session s = openSession();
1
Session s = openSession();
2
		Category c = new Category();
2
		
3
		c.setName("NAME");
4
		Assignable assn = new Assignable();
5
		assn.setId("i.d.");
6
		List l = new ArrayList();
7
		l.add(c);
8
		assn.setCategories(l);
9
		c.setAssignable(assn
3
W w1 = new W();
4
		W w2 = new W();
5
		Z z = new Z();
6
		z.setW(w1);
7
		s.save(z);
10
);
8
		s.flush();
11
		s.save(assn);
9
		z.setW(w2);
12
		s.flush();
10
		s.flush();
13
		s.connection().commit();
11
		s.connection().commit();
14
		s.close();
12
		s.close();
15
		s = openSession();
13
		s = openSession();
16
		s.delete(assn
14
		s.update(z);
15
		s.flush();
16
		s.delete(z);
17
);
17
		s.delete("from W");
18
		s.flush();
18
		s.flush();
19
		s.connection().commit();
19
		s.connection().commit();
20
		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 declared in the same class
Number of node comparisons172
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment9
    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
    W w1 = new W();
    2
    Category c = new Category();
                                                              
                                    
    3
    W w2 = new W();
    3
    c.setName("NAME");
    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
                                              
                                  
    4
    Z z = new Z();
    4
    Assignable assn = new Assignable();
                                                                            
                                
    5
    z.setW(w1);
    Preondition Violations
    Unmatched statement z.setW(w1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    z.setW(w1);
    5
    assn.setId("i.d.");
    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
                                                
    6
    List l = new ArrayList();
                                                        
    7
    l.add(c);
                            
    8
    assn.setCategories(l);
    8
    assn.setCategories(l);
    Preondition Violations
    Unmatched statement assn.setCategories(l); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                      
    9
    c.setAssignable(assn);
    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
                                                      
    10
    s.save(assn);
    10
    s.save(assn);
    6
    s.save(z);
    Differences
    Expression1Expression2Difference
    assnzVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Assignableorg.hibernate.test.legacy.ZVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Assignable of variable assn does not match with type org.hibernate.test.legacy.Z of variable z
    • Make classes org.hibernate.test.legacy.Assignable and org.hibernate.test.legacy.Z extend a common superclass
    6
    s.save(z);
                              
    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
    7
    s.flush();
                                
    8
    z.setW(w2);
    Preondition Violations
    Unmatched statement z.setW(w2); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8
    z.setW(w2);
    11
    s.flush();
    9
    s.flush();
    12
    s.connection().commit();
    10
    s.connection().commit();
    13
    s.close();
    11
    s.close();
    14
    s = openSession();
    12
    s = openSession();
                                    
    13
    s.update(z);
    Preondition Violations
    Unmatched statement s.update(z); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    s.update(z);
                                
    14
    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.flush();
    15
    s.delete(assn);
    15
    s.delete(assn);
    15
    s.delete(z);
    Differences
    Expression1Expression2Difference
    assnzVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Assignableorg.hibernate.test.legacy.ZVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Assignable of variable assn does not match with type org.hibernate.test.legacy.Z of variable z
    • Make classes org.hibernate.test.legacy.Assignable and org.hibernate.test.legacy.Z extend a common superclass
    15
    s.delete(z);
                                                  
    16
    s.delete("from W");
    Preondition Violations
    Unmatched statement s.delete("from W"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    s.delete("from W");
    16
    s.flush();
    17
    s.flush();
    17
    s.connection().commit();
    18
    s.connection().commit();
    18
    s.close();
    19
    s.close();
    Precondition Violations (13)
    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 z.setW(w1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement assn.setId("i.d."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement assn.setCategories(l); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement c.setAssignable(assn); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Type org.hibernate.test.legacy.Assignable of variable assn does not match with type org.hibernate.test.legacy.Z of variable z
    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 z.setW(w2); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9Unmatched statement s.update(z); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Type org.hibernate.test.legacy.Assignable of variable assn does not match with type org.hibernate.test.legacy.Z of variable z
    12Unmatched statement s.delete("from W"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Clone fragment #1 returns variables , while Clone fragment #2 returns variables s