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
    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);
    4
    one.setValue("yada");
                                                    
                                      
    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);
                                            
    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
    assertTrue(Hibernate.isInitialized(e.getJay()));
    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);
    3
    e.setName("Eye Eye");
    Differences
    Expression1Expression2Difference
    assertTruesetNameMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue("many-to-one assoc",many.getOne() != null)e.setName("Eye Eye")ARGUMENT_NUMBER_MISMATCH
    eMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertTrue("many-to-one assoc",many.getOne() != null) is a void method call, and thus it cannot be parameterized
    Expression e.setName("Eye Eye") is a void method call, and thus it cannot be parameterized
    Expression assertTrue("many-to-one assoc",many.getOne() != null) is a void method call, and thus it cannot be parameterized
    Expression e.setName("Eye Eye") is a void method call, and thus it cannot be parameterized
    3
    e.setName("Eye Eye");
                                                                                                                                                                
    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());
    19
    s.delete(many.getOne());
                                                            
    20
    s.delete(many);
                                          
    21
    s.flush();
    20
    s.flush();
    22
    s.connection().commit();
    21
    s.connection().commit();
    23
    s.close();
    22
    s.close();
    Precondition Violations (10)
    Row Violation
    1Unmatched statement s.save(one); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement s.saveOrUpdate(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement s.save(many); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched 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
    5Unmatched 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
    6Unmatched 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
    7Expression assertTrue("many-to-one assoc",many.getOne() != null) is a void method call, and thus it cannot be parameterized
    8Expression e.setName("Eye Eye") is a void method call, and thus it cannot be parameterized
    9Expression assertTrue("many-to-one assoc",many.getOne() != null) is a void method call, and thus it cannot be parameterized
    10Expression e.setName("Eye Eye") is a void method call, and thus it cannot be parameterized