Session s = openSession(); s.beginTransaction(); PropertyValue redValue = new StringPropertyValue( "red" ); PropertyValue lonliestNumberValue = new IntegerPropertyValue( 1 ); Long id; PropertySet ps = new PropertySet( "my properties" ); ps.setSomeSpecificProperty( redValue ); ps.getGeneralProperties().put( "the lonliest number", lonliestNumberValue ); ps.getGeneralProperties().put( "i like", new StringPropertyValue( "pina coladas" ) ); ps.getGeneralProperties().put( "i also like", new StringPropertyValue( "getting caught in the rain" ) ); s.save( ps ); s.getTransaction().commit(); id = ps.getId(); s.clear(); s.beginTransaction(); // TODO : setEntity() currently will not work here, but that would be *very* nice // does not work because the corresponding EntityType is then used as the "bind type" rather // than the "discovered" AnyType... s.createQuery( "from PropertySet p where p.someSpecificProperty = :ssp" ).setParameter( "ssp", redValue ).list(); s.createQuery( "from PropertySet p where p.someSpecificProperty.id is not null" ).list(); s.createQuery( "from PropertySet p join p.generalProperties gp where gp.id is not null" ).list(); s.delete( s.load( PropertySet.class, id ) ); s.getTransaction().commit(); s.close();
Session s = openSession(); Transaction t = s.beginTransaction(); Baz baz = new Baz(); List list = new ArrayList(); list.add( new Fee() ); list.add( new Fee() ); baz.setFees(list); s.save(baz); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); baz = (Baz) s.load( Baz.class, baz.getCode() ); assertTrue( baz.getFees().size()==2 ); s.delete(baz); assertTrue( !s.iterate("from Fee fee").hasNext() ); t.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/hql/ASTParserLoadingTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Method name: void testAnyMappingReference() Method name: void testCascadeSave()
Number of AST nodes: 21 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		Transaction
3
		PropertyValue redValue = new StringPropertyValue( "red" );
4
		PropertyValue lonliestNumberValue = new IntegerPropertyValue( 1 
3
 t = s.beginTransaction();
5
);
4
		Baz baz = new Baz();
6
		Long id;
5
		L
7
		PropertySet ps = new PropertySet( "my properties" );
8
		ps.setSomeSpecificProperty( redValue );
9
		ps.getGeneralProperties().put( "the lonliest number", lonliestNumberValue );
10
		ps.getGeneralProperties().put( "i like", new StringPropertyValue( "pina coladas" ) );
11
		ps.getGeneralProperties().put( "i also like", new StringPropertyValue( "getting caught in the rain" ) 
6
ist list = new ArrayList();
7
		list.add( new Fee() );
8
		list.add( new Fee() );
12
);
9
		baz.setFees(list);
13
		s.save( ps );
10
		s.save(baz);
14
		s.getTransaction().commit();
11
		
15
		id = ps.getId
12
t.commit();
16
();
13
		s.close();
17
		s.clear();
14
		s = openSession();
18
		s.beginTransaction();
15
		t = s.beginTransaction();
19
		// TODO : setEntity() currently will not work here, but that would be *very* nice
16
		
20
		// does not work because the corresponding EntityType is then used as the "bind type" rather
21
		// than the "discovered" AnyType...
22
		s.createQuery( "from PropertySet p where p.someSpecificProperty = :ssp" ).setParameter( "ssp", redValue ).list(
17
baz = (Baz) s.load( Baz.class, baz.getCode() );
18
		assertTrue( baz.getFees().size()==2 );
23
);
19
		s.delete(baz);
24
		s.createQuery( "from PropertySet p where p.someSpecificProperty.id is not null" ).list();
20
		
25
		s.createQuery( "from PropertySet p join p.generalProperties gp where gp.id is not null" ).list();
26
		s.delete( s.load( PropertySet.class, id ) );
21
assertTrue( !s.iterate("from Fee fee").hasNext() );
27
		s.getTransaction().commit();
22
		t.commit();
28
		s.close();
23
		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 comparisons378
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment18
    Number of unmapped statements in the second code fragment15
    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();
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    1
    Session s = openSession();
                                                                                
    2
    Transaction t = s.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    Transaction t = s.beginTransaction();
    2
    s.beginTransaction();
    2
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
                                              
    3
    Baz baz = new Baz();
    3
    PropertyValue redValue = new StringPropertyValue("red");
    3
    PropertyValue redValue = new StringPropertyValue("red");
    Preondition Violations
    Unmatched statement PropertyValue redValue=new StringPropertyValue("red"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                      
                                                              
    4
    List list = new ArrayList();
    4
    PropertyValue lonliestNumberValue = new IntegerPropertyValue(1);
    4
    PropertyValue lonliestNumberValue = new IntegerPropertyValue(1);
    Preondition Violations
    Unmatched statement PropertyValue lonliestNumberValue=new IntegerPropertyValue(1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                      
                                                  
    5
    list.add(new Fee());
    5
    Long id;
                          
                                                  
    6
    list.add(new Fee());
    6
    PropertySet ps = new PropertySet("my properties");
    6
    PropertySet ps = new PropertySet("my properties");
    Preondition Violations
    Unmatched statement PropertySet ps=new PropertySet("my properties"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                          
                                              
    7
    baz.setFees(list);
    Preondition Violations
    Unmatched statement baz.setFees(list); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7
    baz.setFees(list);
    7
    ps.setSomeSpecificProperty(redValue);
    7
    ps.setSomeSpecificProperty(redValue);
    Preondition Violations
    Unmatched statement ps.setSomeSpecificProperty(redValue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                    
    8
    ps.getGeneralProperties().put("the lonliest number", lonliestNumberValue);
                                                                                                                                                            
    9
    ps.getGeneralProperties().put("i like", new StringPropertyValue("pina coladas"));
                                                                                                                                                                          
    10
    ps.getGeneralProperties().put("i also like", new StringPropertyValue("getting caught in the rain"));
                                                                                                                                                                                                                  
    11
    s.save(ps);
    11
    s.save(ps);
    8
    s.save(baz);
    Differences
    Expression1Expression2Difference
    psbazVARIABLE_NAME_MISMATCH
    org.hibernate.test.any.PropertySetorg.hibernate.test.legacy.BazVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.any.PropertySet of variable ps does not match with type org.hibernate.test.legacy.Baz of variable baz
    • Make classes org.hibernate.test.any.PropertySet and org.hibernate.test.legacy.Baz extend a common superclass
    8
    s.save(baz);
                                
    9
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9
    t.commit();
                                            
    11
    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
    11
    s = openSession();
                                                          
    12
    t = s.beginTransaction();
    12
    s.getTransaction().commit();
    12
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
                                                                                              
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
    Preondition Violations
    Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
    13
    id = ps.getId();
                                        
                                                                                        
    14
    assertTrue(baz.getFees().size() == 2);
    14
    s.clear();
    14
    s.clear();
    Preondition Violations
    Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
                                        
    15
    s.delete(baz);
    15
    s.beginTransaction();
    15
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                      
                                                                                                              
    16
    assertTrue(!s.iterate("from Fee fee").hasNext());
    Preondition Violations
    Unmatched statement assertTrue(!s.iterate("from Fee fee").hasNext()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16
    assertTrue(!s.iterate("from Fee fee").hasNext());
    16
    s.createQuery("from PropertySet p where p.someSpecificProperty = :ssp").setParameter("ssp", redValue).list();
    16
    s.createQuery("from PropertySet p where p.someSpecificProperty = :ssp").setParameter("ssp", redValue).list();
    Preondition Violations
    Unmatched statement s.createQuery("from PropertySet p where p.someSpecificProperty = :ssp").setParameter("ssp",redValue).list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                                    
                                  
    17
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    17
    t.commit();
    17
    s.createQuery("from PropertySet p where p.someSpecificProperty.id is not null").list();
    17
    s.createQuery("from PropertySet p where p.someSpecificProperty.id is not null").list();
    Preondition Violations
    Unmatched statement s.createQuery("from PropertySet p where p.someSpecificProperty.id is not null").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                          
                                
    18
    s.close();
    18
    s.createQuery("from PropertySet p join p.generalProperties gp where gp.id is not null").list();
    18
    s.createQuery("from PropertySet p join p.generalProperties gp where gp.id is not null").list();
    Preondition Violations
    Unmatched statement s.createQuery("from PropertySet p join p.generalProperties gp where gp.id is not null").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                          
    19
    s.delete(s.load(PropertySet.class, id));
    19
    s.delete(s.load(PropertySet.class, id));
    Preondition Violations
    Unmatched statement s.delete(s.load(PropertySet.class,id)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                          
    20
    s.getTransaction().commit();
    20
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
    21
    s.close();
    21
    s.close();
    10
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    10
    s.close();
    Precondition Violations (22)
    Row Violation
    1Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement PropertyValue redValue=new StringPropertyValue("red"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement PropertyValue lonliestNumberValue=new IntegerPropertyValue(1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement PropertySet ps=new PropertySet("my properties"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement baz.setFees(list); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement ps.setSomeSpecificProperty(redValue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Type org.hibernate.test.any.PropertySet of variable ps does not match with type org.hibernate.test.legacy.Baz of variable baz
    9Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement assertTrue(!s.iterate("from Fee fee").hasNext()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16Unmatched statement s.createQuery("from PropertySet p where p.someSpecificProperty = :ssp").setParameter("ssp",redValue).list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    18Unmatched statement s.createQuery("from PropertySet p where p.someSpecificProperty.id is not null").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement s.createQuery("from PropertySet p join p.generalProperties gp where gp.id is not null").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement s.delete(s.load(PropertySet.class,id)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Clone fragment #1 returns variable s with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session