getSessions().getStatistics().clear(); Session s = openSession(); Transaction t = s.beginTransaction(); User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") ); s.persist(u); s.flush(); u.getPerson().setName("XXXXYYYYY"); t.commit(); s.close(); assertEquals( 1, getSessions().getStatistics().getEntityInsertCount() ); assertEquals( 0, getSessions().getStatistics().getEntityUpdateCount() ); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "gavin"); assertEquals( u.getPerson().getName(), "Gavin King" ); s.delete(u); t.commit(); s.close(); assertEquals( 1, getSessions().getStatistics().getEntityDeleteCount() );
getSessions().getStatistics().clear(); Session s = openSession(); Transaction t = s.beginTransaction(); User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") ); s.persist(u); s.flush(); u.getPerson().setName("XXXXYYYYY"); t.commit(); s.close(); assertEquals( 1, getSessions().getStatistics().getEntityInsertCount() ); assertEquals( 0, getSessions().getStatistics().getEntityUpdateCount() ); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "gavin"); assertEquals( u.getPerson().getName(), "Gavin King" ); s.delete(u); t.commit(); s.close(); assertEquals( 1, getSessions().getStatistics().getEntityDeleteCount() );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/component/basic/ComponentTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/timestamp/TimestampTest.java
Method name: void testUpdateFalse() Method name: void testUpdateFalse()
Number of AST nodes: 19 Number of AST nodes: 19
1
getSessions().getStatistics().clear();
1
getSessions().getStatistics().clear();
2
		
2
		
3
		Session s = openSession();
3
		Session s = openSession();
4
		Transaction t = s.beginTransaction();
4
		Transaction t = s.beginTransaction();
5
		User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );
5
		User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );
6
		s.persist(u);
6
		s.persist(u);
7
		s.flush();
7
		s.flush();
8
		u.getPerson().setName("XXXXYYYYY");
8
		u.getPerson().setName("XXXXYYYYY");
9
		t.commit();
9
		t.commit();
10
		s.close();
10
		s.close();
11
		
11
		
12
		assertEquals( 1, getSessions().getStatistics().getEntityInsertCount() );
12
		assertEquals( 1, getSessions().getStatistics().getEntityInsertCount() );
13
		assertEquals( 0, getSessions().getStatistics().getEntityUpdateCount() );
13
		assertEquals( 0, getSessions().getStatistics().getEntityUpdateCount() );
14
		s = openSession();
14
		s = openSession();
15
		t = s.beginTransaction();
15
		t = s.beginTransaction();
16
		u = (User) s.get(User.class, "gavin");
16
		u = (User) s.get(User.class, "gavin");
17
		assertEquals( u.getPerson().getName(), "Gavin King" );
17
		assertEquals( u.getPerson().getName(), "Gavin King" );
18
		s.delete(u);
18
		s.delete(u);
19
		t.commit();
19
		t.commit();
20
		s.close();
20
		s.close();
21
		
21
		
22
		assertEquals( 1, getSessions().getStatistics().getEntityDeleteCount() );
22
		assertEquals( 1, getSessions().getStatistics().getEntityDeleteCount() );
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 comparisons212
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    getSessions().getStatistics().clear();
    1
    getSessions().getStatistics().clear();
    2
    Session s = openSession();
    2
    Session s = openSession();
    3
    Transaction t = s.beginTransaction();
    3
    Transaction t = s.beginTransaction();
                                                                                                                                                                                      
    4
    User u = new User("gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave"));
    Preondition Violations
    Unmatched statement User u=new User("gavin","secret",new Person("Gavin King",new Date(),"Karbarook Ave")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    User u = new User("gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave"));
    4
    User u = new User("gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave"));
    4
    User u = new User("gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave"));
    Preondition Violations
    Unmatched statement User u=new User("gavin","secret",new Person("Gavin King",new Date(),"Karbarook Ave")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                      
    5
    s.persist(u);
    5
    s.persist(u);
    5
    s.persist(u);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.component.basic.Userorg.hibernate.test.timestamp.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    • Make classes org.hibernate.test.component.basic.User and org.hibernate.test.timestamp.User extend a common superclass
    5
    s.persist(u);
    6
    s.flush();
    6
    s.flush();
    7
    u.getPerson().setName("XXXXYYYYY");
    7
    u.getPerson().setName("XXXXYYYYY");
    7
    u.getPerson().setName("XXXXYYYYY");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.component.basic.Personorg.hibernate.test.timestamp.PersonVARIABLE_TYPE_MISMATCH
    org.hibernate.test.component.basic.Userorg.hibernate.test.timestamp.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.component.basic.Person of variable u.getPerson() does not match with type org.hibernate.test.timestamp.Person of variable u.getPerson()
    • Make classes org.hibernate.test.component.basic.Person and org.hibernate.test.timestamp.Person extend a common superclass
    Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    • Make classes org.hibernate.test.component.basic.User and org.hibernate.test.timestamp.User extend a common superclass
    7
    u.getPerson().setName("XXXXYYYYY");
    8
    t.commit();
    8
    t.commit();
    9
    s.close();
    9
    s.close();
    10
    assertEquals(1, getSessions().getStatistics().getEntityInsertCount());
    10
    assertEquals(1, getSessions().getStatistics().getEntityInsertCount());
    11
    assertEquals(0, getSessions().getStatistics().getEntityUpdateCount());
    11
    assertEquals(0, getSessions().getStatistics().getEntityUpdateCount());
    12
    s = openSession();
    12
    s = openSession();
    13
    t = s.beginTransaction();
    13
    t = s.beginTransaction();
                                                                                
    14
    u = (User)s.get(User.class, "gavin");
    Preondition Violations
    Unmatched statement u=(User)s.get(User.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    u = (User)s.get(User.class, "gavin");
    14
    u = (User)s.get(User.class, "gavin");
    14
    u = (User)s.get(User.class, "gavin");
    Preondition Violations
    Unmatched statement u=(User)s.get(User.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    15
    assertEquals(u.getPerson().getName(), "Gavin King");
    15
    assertEquals(u.getPerson().getName(), "Gavin King");
    15
    assertEquals(u.getPerson().getName(), "Gavin King");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.component.basic.Personorg.hibernate.test.timestamp.PersonVARIABLE_TYPE_MISMATCH
    org.hibernate.test.component.basic.Userorg.hibernate.test.timestamp.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.component.basic.Person of variable u.getPerson() does not match with type org.hibernate.test.timestamp.Person of variable u.getPerson()
    • Make classes org.hibernate.test.component.basic.Person and org.hibernate.test.timestamp.Person extend a common superclass
    Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    • Make classes org.hibernate.test.component.basic.User and org.hibernate.test.timestamp.User extend a common superclass
    15
    assertEquals(u.getPerson().getName(), "Gavin King");
    16
    s.delete(u);
    16
    s.delete(u);
    16
    s.delete(u);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.component.basic.Userorg.hibernate.test.timestamp.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    • Make classes org.hibernate.test.component.basic.User and org.hibernate.test.timestamp.User extend a common superclass
    16
    s.delete(u);
    17
    t.commit();
    17
    t.commit();
    18
    s.close();
    18
    s.close();
    19
    assertEquals(1, getSessions().getStatistics().getEntityDeleteCount());
    19
    assertEquals(1, getSessions().getStatistics().getEntityDeleteCount());
    Precondition Violations (14)
    Row Violation
    1Unmatched statement User u=new User("gavin","secret",new Person("Gavin King",new Date(),"Karbarook Ave")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement User u=new User("gavin","secret",new Person("Gavin King",new Date(),"Karbarook Ave")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    4Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type org.hibernate.test.component.basic.Person of variable u.getPerson() does not match with type org.hibernate.test.timestamp.Person of variable u.getPerson()
    7Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    8Unmatched statement u=(User)s.get(User.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement u=(User)s.get(User.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression u.getPerson() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Type org.hibernate.test.component.basic.Person of variable u.getPerson() does not match with type org.hibernate.test.timestamp.Person of variable u.getPerson()
    13Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u
    14Type org.hibernate.test.component.basic.User of variable u does not match with type org.hibernate.test.timestamp.User of variable u