Session s = openSession( new PropertyInterceptor() ); Transaction t = s.beginTransaction(); User u = new User("Gavin", "nivag"); s.persist(u); u.setPassword("vagni"); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "Gavin"); assertNotNull( u.getCreated() ); assertNotNull( u.getLastUpdated() ); s.delete(u); t.commit(); s.close();
Session s = openSession( new CollectionInterceptor() ); Transaction t = s.beginTransaction(); User u = new User("Gavin", "nivag"); s.persist(u); u.setPassword("vagni"); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "Gavin"); assertEquals( 2, u.getActions().size() ); s.delete(u); 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/interceptor/InterceptorTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java
Method name: void testPropertyIntercept() Method name: void testCollectionIntercept()
Number of AST nodes: 15 Number of AST nodes: 14
1
Session s = openSession( new PropertyInterceptor() );
1
Session s = openSession( new CollectionInterceptor() );
2
		Transaction t = s.beginTransaction();
2
		Transaction t = s.beginTransaction();
3
		User u = new User("Gavin", "nivag");
3
		User u = new User("Gavin", "nivag");
4
		s.persist(u);
4
		s.persist(u);
5
		u.setPassword("vagni");
5
		u.setPassword("vagni");
6
		t.commit();
6
		t.commit();
7
		s.close();
7
		s.close();
8
		s = openSession();
8
		s = openSession();
9
		t = s.beginTransaction();
9
		t = s.beginTransaction();
10
		u = (User) s.get(User.class, "Gavin");
10
		u = (User) s.get(User.class, "Gavin");
11
		assertNotNull( u.getCreated() );
11
		assert
12
		assertNotNull( u.getLastUpdated() );
12
Equals( 2, u.getActions().size() );
13
		s.delete(u);
13
		s.delete(u);
14
		t.commit();
14
		t.commit();
15
		s.close();
15
		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 declared in the same class
Number of node comparisons79
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession(new PropertyInterceptor());
    1
    Session s = openSession(new PropertyInterceptor());
    1
    Session s = openSession(new CollectionInterceptor());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.interceptor.PropertyInterceptororg.hibernate.test.interceptor.CollectionInterceptorSUBCLASS_TYPE_MISMATCH
    1
    Session s = openSession(new CollectionInterceptor());
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    3
    User u = new User("Gavin", "nivag");
    3
    User u = new User("Gavin", "nivag");
    4
    s.persist(u);
    4
    s.persist(u);
    5
    u.setPassword("vagni");
    5
    u.setPassword("vagni");
    6
    t.commit();
    6
    t.commit();
    7
    s.close();
    7
    s.close();
    8
    s = openSession();
    8
    s = openSession();
    9
    t = s.beginTransaction();
    9
    t = s.beginTransaction();
    10
    u = (User)s.get(User.class, "Gavin");
    10
    u = (User)s.get(User.class, "Gavin");
    11
    assertNotNull(u.getCreated());
    11
    assertNotNull(u.getCreated());
    11
    assertEquals(2, u.getActions().size());
    Differences
    Expression1Expression2Difference
    assertNotNullassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertNotNull(u.getCreated())assertEquals(2,u.getActions().size())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    11
    assertEquals(2, u.getActions().size());
    12
    assertNotNull(u.getLastUpdated());
                                                                                
    13
    s.delete(u);
    12
    s.delete(u);
    14
    t.commit();
    13
    t.commit();
    15
    s.close();
    14
    s.close();
    Precondition Violations (9)
    Row Violation
    1Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    4Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    5Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    8Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    9Clone fragment #1 returns variables u , while Clone fragment #2 returns variables