Session s = openSession(); One one = new One(); s.save(one); one.setValue("yada"); Many many = new Many(); many.setOne(one); s.save(many); s.flush(); s.connection().commit(); s.close(); s = openSession(); one = (One) s.load( One.class, one.getKey() ); one.getManies().size(); s.connection().commit(); s.close(); s = openSession(); many = (Many) s.load( Many.class, many.getKey() ); assertTrue( "many-to-one assoc", many.getOne()!=null ); s.delete( many.getOne() ); s.delete(many); s.flush(); s.connection().commit(); s.close();
Session s = openSession(); Eye e = new Eye(); e.setName("Eye Eye"); Jay jay = new Jay(e); e.setJay(jay); s.saveOrUpdate(e); s.flush(); s.connection().commit(); s.close(); s = openSession(); e = (Eye) s.createCriteria(Eye.class).uniqueResult(); assertTrue( Hibernate.isInitialized( e.getJay() ) ); assertTrue( Hibernate.isInitialized( e.getJays() ) ); s.connection().commit(); s.close(); s = openSession(); jay = (Jay) s.createQuery("select new Jay(eye) from Eye eye").uniqueResult(); assertTrue( "Eye Eye".equals( jay.getEye().getName() ) ); s.delete( jay.getEye() ); 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 testManyToOne() Method name: void testOuterJoin()
Number of AST nodes: 23 Number of AST nodes: 22
1
Session s = openSession();
1
Session s = openSession();
2
		One one = new One();
2
		Eye e = new Eye();
3
		s.save(one);
3
		
4
		one.setValue("yada");
4
e.setName("Eye Eye");
5
		Many many = new Many();
5
		Jay jay = new Jay(e);
6
		many.setOne(one);
6
		e.setJay(jay);
7
		s.save(many);
7
		s.saveOrUpdate(e);
8
		s.flush();
8
		s.flush();
9
		s.connection().commit();
9
		s.connection().commit();
10
		s.close();
10
		s.close();
11
		s = openSession();
11
		s = openSession();
12
		one = (One) s.load( One.class, on
12
		e = (Eye) s.createCriteria(Eye.class).uniqueResult();
13
e.getKey() );
13
		assertTrue( Hibernate.isInitialized( e.getJay() ) );
14
		one.getManies().size();
14
		assertTrue( Hibernate.isInitialized( e.getJays() ) );
15
		s.connection().commit();
15
		s.connection().commit();
16
		s.close();
16
		s.close();
17
		s = openSession();
17
		s = openSession();
18
		many = (Many) s.load( Many.class, many.getKey() );
18
		jay = (Jay) s.
19
		assertTrue( "many-to-one assoc", many.getOne()!=null
19
createQuery("select new Jay(eye) from Eye eye").uniqueResult();
20
 );
20
		assertTrue( "Eye Eye".equals( jay.getEye().getName() ) );
21
		s.delete( many.getOne() );
21
		s.delete( jay.getEye() );
22
		s.delete(many);
22
		
23
		s.flush();
23
s.flush();
24
		s.connection().commit();
24
		s.connection().commit();
25
		s.close();
25
		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 comparisons182
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment11
    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 s = openSession();
                                          
    2
    Eye e = new Eye();
    2
    One one = new One();
                                              
                                                    
    3
    e.setName("Eye Eye");
    Preondition Violations
    Unmatched statement e.setName("Eye Eye"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    e.setName("Eye Eye");
    3
    s.save(one);
    3
    s.save(one);
    Preondition Violations
    Unmatched statement s.save(one); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
                                                
    4
    Jay jay = new Jay(e);
    Preondition Violations
    Unmatched statement Jay jay=new Jay(e); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    Jay jay = new Jay(e);
    4
    one.setValue("yada");
    4
    one.setValue("yada");
    Preondition Violations
    Unmatched statement one.setValue("yada"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                    
                                      
    5
    e.setJay(jay);
    Preondition Violations
    Unmatched statement e.setJay(jay); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    e.setJay(jay);
    5
    Many many = new Many();
                                                    
                                              
    6
    s.saveOrUpdate(e);
    Preondition Violations
    Unmatched statement s.saveOrUpdate(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    s.saveOrUpdate(e);
    6
    many.setOne(one);
    6
    many.setOne(one);
    Preondition Violations
    Unmatched statement many.setOne(one); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                            
    7
    s.save(many);
    7
    s.save(many);
    Preondition Violations
    Unmatched statement s.save(many); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    8
    s.flush();
    7
    s.flush();
    9
    s.connection().commit();
    8
    s.connection().commit();
    10
    s.close();
    9
    s.close();
    11
    s = openSession();
    10
    s = openSession();
                                                                                                                
    11
    e = (Eye)s.createCriteria(Eye.class).uniqueResult();
    Preondition Violations
    Unmatched statement e=(Eye)s.createCriteria(Eye.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    e = (Eye)s.createCriteria(Eye.class).uniqueResult();
    12
    one = (One)s.load(One.class, one.getKey());
    12
    one = (One)s.load(One.class, one.getKey());
    Preondition Violations
    Unmatched statement one=(One)s.load(One.class,one.getKey()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
                                                                                                              
    13
    assertTrue(Hibernate.isInitialized(e.getJays()));
    13
    one.getManies().size();
                                                          
    14
    s.connection().commit();
    14
    s.connection().commit();
    15
    s.close();
    15
    s.close();
    16
    s = openSession();
    16
    s = openSession();
    17
    many = (Many)s.load(Many.class, many.getKey());
    17
    many = (Many)s.load(Many.class, many.getKey());
    Preondition Violations
    Unmatched statement many=(Many)s.load(Many.class,many.getKey()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                    
    18
    assertTrue("many-to-one assoc", many.getOne() != null);
    18
    assertTrue("many-to-one assoc", many.getOne() != null);
    12
    assertTrue(Hibernate.isInitialized(e.getJay()));
    Differences
    Expression1Expression2Difference
    assertTrue("many-to-one assoc",many.getOne() != null)assertTrue(Hibernate.isInitialized(e.getJay()))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertTrue("many-to-one assoc",many.getOne() != null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(Hibernate.isInitialized(e.getJay())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue("many-to-one assoc",many.getOne() != null) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(Hibernate.isInitialized(e.getJay())) is a void method call, and thus it cannot be parameterized
    12
    assertTrue(Hibernate.isInitialized(e.getJay()));
                                                                                                                                                                
    17
    jay = (Jay)s.createQuery("select new Jay(eye) from Eye eye").uniqueResult();
    Preondition Violations
    Unmatched statement jay=(Jay)s.createQuery("select new Jay(eye) from Eye eye").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    jay = (Jay)s.createQuery("select new Jay(eye) from Eye eye").uniqueResult();
                                                                                                                      
    18
    assertTrue("Eye Eye".equals(jay.getEye().getName()));
                                                          
    19
    s.delete(jay.getEye());
    Preondition Violations
    Unmatched statement s.delete(jay.getEye()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19
    s.delete(jay.getEye());
    19
    s.delete(many.getOne());
    19
    s.delete(many.getOne());
    Preondition Violations
    Unmatched statement s.delete(many.getOne()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    20
    s.delete(many);
    20
    s.delete(many);
    Preondition Violations
    Unmatched statement s.delete(many); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
    21
    s.flush();
    20
    s.flush();
    22
    s.connection().commit();
    21
    s.connection().commit();
    23
    s.close();
    22
    s.close();
    Precondition Violations (19)
    Row Violation
    1Unmatched statement e.setName("Eye Eye"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement s.save(one); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Jay jay=new Jay(e); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement one.setValue("yada"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement e.setJay(jay); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement s.saveOrUpdate(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement many.setOne(one); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement s.save(many); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement e=(Eye)s.createCriteria(Eye.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement one=(One)s.load(One.class,one.getKey()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement many=(Many)s.load(Many.class,many.getKey()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Expression assertTrue("many-to-one assoc",many.getOne() != null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression assertTrue(Hibernate.isInitialized(e.getJay())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression assertTrue("many-to-one assoc",many.getOne() != null) is a void method call, and thus it cannot be parameterized
    15Expression assertTrue(Hibernate.isInitialized(e.getJay())) is a void method call, and thus it cannot be parameterized
    16Unmatched statement jay=(Jay)s.createQuery("select new Jay(eye) from Eye eye").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement s.delete(jay.getEye()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement s.delete(many.getOne()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement s.delete(many); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted