Configuration cfg = new Configuration(); assertNotNull( cfg.getEventListeners().getDeleteEventListeners() ); cfg.setListener( "delete", DeleteListenerForTest.class.getName() ); assertEquals( 1, cfg.getEventListeners().getDeleteEventListeners().length ); assertTrue( cfg.getEventListeners().getDeleteEventListeners()[0] instanceof DeleteListenerForTest );
Session s = openSession(); Transaction t = s.beginTransaction(); //this test raise an exception right now HHH-570 assertEquals( 0, s.createQuery("from Parent p where size(p.children) = 0").list().size() ); assertEquals( 0, s.createQuery("from Parent p where p.children.size = 0").list().size() ); 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/cfg/ListenerTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/onetomany/OneToManyTest.java
Method name: void testSetListenerClassName() Method name: void testManyToManySize()
Number of AST nodes: 5 Number of AST nodes: 6
1
Configuration cfg = new Configuration();
1
Session 
2
		assertNotNull( cfg.getEventListeners().getDeleteEventListeners() );
3
		cfg.setListener( "delete", DeleteListenerForTest.class.getName() );
2
s = openSession();
3
		Transaction t = s.beginTransaction();
4
		//this test raise an exception right now HHH-570
4
		assertEquals( 1, cfg.getEventListeners().getDeleteEventListeners().length );
5
		assertEquals( 0, 
5
		assertTrue( cfg.getEventListeners().getDeleteEventListeners()[0] instanceof DeleteListenerForTest 
6
s.createQuery("from Parent p where size(p.children) = 0").list().size() );
7
		assertEquals( 0, s.createQuery("from Parent p where p.children.size = 0").list().size() );
8
		t.commit();
6
);
9
		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 comparisons30
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                          
    1
    Session s = openSession();
    Preondition Violations
    Unmatched statement Session s=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    Session s = openSession();
    1
    Configuration cfg = new Configuration();
    1
    Configuration cfg = new Configuration();
    Preondition Violations
    Unmatched statement Configuration cfg=new Configuration(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                      
                                                                                
    2
    Transaction t = s.beginTransaction();
    2
    assertNotNull(cfg.getEventListeners().getDeleteEventListeners());
    2
    assertNotNull(cfg.getEventListeners().getDeleteEventListeners());
    3
    assertEquals(0, s.createQuery("from Parent p where size(p.children) = 0").list().size());
    Differences
    Expression1Expression2Difference
    assertNotNullassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertNotNull(cfg.getEventListeners().getDeleteEventListeners())assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) is a void method call, and thus it cannot be parameterized
    3
    assertEquals(0, s.createQuery("from Parent p where size(p.children) = 0").list().size());
    3
    cfg.setListener("delete", DeleteListenerForTest.class.getName());
    3
    cfg.setListener("delete", DeleteListenerForTest.class.getName());
    Preondition Violations
    Unmatched statement cfg.setListener("delete",DeleteListenerForTest.class.getName()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                          
    4
    assertEquals(1, cfg.getEventListeners().getDeleteEventListeners().length);
    4
    assertEquals(1, cfg.getEventListeners().getDeleteEventListeners().length);
    4
    assertEquals(0, s.createQuery("from Parent p where p.children.size = 0").list().size());
    Differences
    Expression1Expression2Difference
    10LITERAL_VALUE_MISMATCH
    cfg.getEventListeners().getDeleteEventListeners().lengths.createQuery("from Parent p where p.children.size = 0").list().size()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression cfg.getEventListeners().getDeleteEventListeners().length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.createQuery("from Parent p where p.children.size = 0").list().size() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    assertEquals(0, s.createQuery("from Parent p where p.children.size = 0").list().size());
                                
    5
    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
    5
    t.commit();
    5
    assertTrue(cfg.getEventListeners().getDeleteEventListeners()[0] instanceof DeleteListenerForTest);
                                                                                                                                                                                                              
                              
    6
    s.close();
    Precondition Violations (14)
    Row Violation
    1Unmatched statement Session s=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement Configuration cfg=new Configuration(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) is a void method call, and thus it cannot be parameterized
    6Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) is a void method call, and thus it cannot be parameterized
    7Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression assertNotNull(cfg.getEventListeners().getDeleteEventListeners()) is a void method call, and thus it cannot be parameterized
    10Expression assertEquals(0,s.createQuery("from Parent p where size(p.children) = 0").list().size()) is a void method call, and thus it cannot be parameterized
    11Unmatched statement cfg.setListener("delete",DeleteListenerForTest.class.getName()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Expression cfg.getEventListeners().getDeleteEventListeners().length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression s.createQuery("from Parent p where p.children.size = 0").list().size() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted