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(); 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/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 testNoUpdateManyToOne()
Number of AST nodes: 17 Number of AST nodes: 19
1
Session s = openSession();
1
Session s = openSession();
2
		Baz baz = new Baz();
2
		W w1 = new W();
3
		List list = new ArrayList();
3
		
4
		baz.setBazez(list);
5
		list.add( new Baz() 
4
W w2 = new W();
5
		Z z = new Z();
6
);
6
		z.setW(w1);
7
		s.save(baz);
7
		s.save(z);
8
		s.flush();
8
		s.flush();
9
		list.add( new Baz() );
9
		
10
		s.flush();
11
		list.add( 0, new Baz() 
10
z.setW(w2);
11
		s.flush();
12
);
12
		s.connection().commit();
13
		s.flush();
13
		s.close();
14
		s.delete( list.remove(1) 
14
		s = openSession();
15
);
15
		s.update(z);
16
		s.flush();
16
		s.flush();
17
		s.delete(baz
17
		s.delete(z);
18
);
18
		s.delete("from W");
19
		s.flush();
19
		s.flush();
20
		s.connection().commit();
20
		s.connection().commit();
21
		s.close();
21
		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 comparisons215
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment7
    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
    Baz baz = new Baz();
                                              
                                    
    3
    W w2 = new W();
    3
    List list = new ArrayList();
                                                              
                                  
    4
    Z z = new Z();
    4
    baz.setBazez(list);
                                                
                                
    5
    z.setW(w1);
    5
    list.add(new Baz());
                                                  
    6
    s.save(baz);
    6
    s.save(baz);
    6
    s.save(z);
    Differences
    Expression1Expression2Difference
    bazzVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.ZVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Z of variable z
    • Make classes org.hibernate.test.legacy.Baz and org.hibernate.test.legacy.Z extend a common superclass
    6
    s.save(z);
    7
    s.flush();
    7
    s.flush();
                                
    8
    z.setW(w2);
    8
    list.add(new Baz());
                                                  
    9
    s.flush();
    9
    s.flush();
                                                            
    10
    s.connection().commit();
    10
    list.add(0, new Baz());
                                                        
                                            
    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();
    11
    s.flush();
    11
    s.flush();
    13
    s.update(z);
    Differences
    Expression1Expression2Difference
    flushupdateMETHOD_INVOCATION_NAME_MISMATCH
    s.flush()s.update(z)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression s.update(z) is a void method call, and thus it cannot be parameterized
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression s.update(z) is a void method call, and thus it cannot be parameterized
    13
    s.update(z);
    12
    s.delete(list.remove(1));
                                                              
    13
    s.flush();
    14
    s.flush();
    14
    s.delete(baz);
    14
    s.delete(baz);
    15
    s.delete(z);
    Differences
    Expression1Expression2Difference
    bazzVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.ZVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Z of variable z
    • Make classes org.hibernate.test.legacy.Baz and org.hibernate.test.legacy.Z extend a common superclass
    15
    s.delete(z);
                                                  
    16
    s.delete("from W");
    15
    s.flush();
    17
    s.flush();
    16
    s.connection().commit();
    18
    s.connection().commit();
    17
    s.close();
    11
    s.close();
                                
    19
    s.close();
    Precondition Violations (9)
    Row Violation
    1Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Z of variable z
    2Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression s.flush() is a void method call, and thus it cannot be parameterized
    5Expression s.update(z) is a void method call, and thus it cannot be parameterized
    6Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression s.flush() is a void method call, and thus it cannot be parameterized
    8Expression s.update(z) is a void method call, and thus it cannot be parameterized
    9Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Z of variable z