Session s = openSession(); Transaction t = s.beginTransaction(); User gavin = new User("gavin", "secret"); User turin = new User("turin", "tiger"); gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") ); gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") ); s.persist(gavin); s.persist(turin); s.flush(); s.clear(); List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list(); assertEquals( results.size(), 2 ); gavin = (User) ( (Object[]) results.get(0) )[0]; assertEquals( gavin.getName(), "gavin" ); assertEquals( gavin.getSession().size(), 2 ); s.createQuery("delete SessionAttribute").executeUpdate(); s.createQuery("delete User").executeUpdate(); t.commit(); s.close();
Session s = openSession(); Transaction t = s.beginTransaction(); User gavin = new User("gavin", "secret"); User turin = new User("turin", "tiger"); gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") ); gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") ); s.persist(gavin); s.persist(turin); s.flush(); s.clear(); List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list(); assertEquals( results.size(), 2 ); gavin = (User) ( (Object[]) results.get(0) )[0]; assertEquals( gavin.getName(), "gavin" ); assertEquals( gavin.getSession().size(), 2 ); s.createQuery("delete SessionAttribute").executeUpdate(); s.createQuery("delete User").executeUpdate(); 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/extralazy/ExtraLazyTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/map/MapIndexFormulaTest.java
Method name: void testSQLQuery() Method name: void testSQLQuery()
Number of AST nodes: 19 Number of AST nodes: 19
1
Session s = openSession();
1
Session s = openSession();
2
		Transaction t = s.beginTransaction();
2
		Transaction t = s.beginTransaction();
3
		User gavin = new User("gavin", "secret");
3
		User gavin = new User("gavin", "secret");
4
		User turin = new User("turin", "tiger");
4
		User turin = new User("turin", "tiger");
5
		gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );
5
		gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );
6
		gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") );
6
		gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") );
7
		s.persist(gavin);
7
		s.persist(gavin);
8
		s.persist(turin);
8
		s.persist(turin);
9
		s.flush();
9
		s.flush();
10
		s.clear();
10
		s.clear();
11
		List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();
11
		List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();
12
		assertEquals( results.size(), 2 );
12
		assertEquals( results.size(), 2 );
13
		gavin = (User) ( (Object[]) results.get(0) )[0];
13
		gavin = (User) ( (Object[]) results.get(0) )[0];
14
		assertEquals( gavin.getName(), "gavin" );
14
		assertEquals( gavin.getName(), "gavin" );
15
		assertEquals( gavin.getSession().size(), 2 );
15
		assertEquals( gavin.getSession().size(), 2 );
16
		s.createQuery("delete SessionAttribute").executeUpdate();
16
		s.createQuery("delete SessionAttribute").executeUpdate();
17
		s.createQuery("delete User").executeUpdate();
17
		s.createQuery("delete User").executeUpdate();
18
		t.commit();
18
		t.commit();
19
		s.close();
19
		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 comparisons297
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
                                                                                      
    3
    User gavin = new User("gavin", "secret");
    3
    User gavin = new User("gavin", "secret");
                                                                                      
                                                                                    
    4
    User turin = new User("turin", "tiger");
    4
    User turin = new User("turin", "tiger");
                                                                                    
    5
    gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz"));
    5
    gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz"));
    5
    gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz"));
    Differences
    Expression1Expression2Difference
    org.hibernate.test.extralazy.SessionAttributeorg.hibernate.test.map.SessionAttributeVARIABLE_TYPE_MISMATCH
    org.hibernate.test.extralazy.Userorg.hibernate.test.map.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.SessionAttribute of variable new SessionAttribute("foo","foo bar baz") does not match with type org.hibernate.test.map.SessionAttribute of variable new SessionAttribute("foo","foo bar baz")
    • Make classes org.hibernate.test.extralazy.SessionAttribute and org.hibernate.test.map.SessionAttribute extend a common superclass
    Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.map.User extend a common superclass
    5
    gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz"));
    6
    gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2"));
    6
    gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2"));
    6
    gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2"));
    Differences
    Expression1Expression2Difference
    org.hibernate.test.extralazy.SessionAttributeorg.hibernate.test.map.SessionAttributeVARIABLE_TYPE_MISMATCH
    org.hibernate.test.extralazy.Userorg.hibernate.test.map.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.SessionAttribute of variable new SessionAttribute("bar","foo bar baz 2") does not match with type org.hibernate.test.map.SessionAttribute of variable new SessionAttribute("bar","foo bar baz 2")
    • Make classes org.hibernate.test.extralazy.SessionAttribute and org.hibernate.test.map.SessionAttribute extend a common superclass
    Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.map.User extend a common superclass
    6
    gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2"));
    7
    s.persist(gavin);
    7
    s.persist(gavin);
    7
    s.persist(gavin);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.extralazy.Userorg.hibernate.test.map.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.map.User extend a common superclass
    7
    s.persist(gavin);
    8
    s.persist(turin);
    8
    s.persist(turin);
    8
    s.persist(turin);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.extralazy.Userorg.hibernate.test.map.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.map.User of variable turin
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.map.User extend a common superclass
    8
    s.persist(turin);
    9
    s.flush();
    9
    s.flush();
    10
    s.clear();
    10
    s.clear();
    11
    List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();
    11
    List results = s.getNamedQuery("userSessionData").setParameter("uname", "%in").list();
    12
    assertEquals(results.size(), 2);
    12
    assertEquals(results.size(), 2);
                                                                                                
    13
    gavin = (User)((Object[])results.get(0))[0];
    Preondition Violations
    Unmatched statement gavin=(User)((Object[])results.get(0))[0]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    gavin = (User)((Object[])results.get(0))[0];
    13
    gavin = (User)((Object[])results.get(0))[0];
    13
    gavin = (User)((Object[])results.get(0))[0];
    Preondition Violations
    Unmatched statement gavin=(User)((Object[])results.get(0))[0]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                
    14
    assertEquals(gavin.getName(), "gavin");
    14
    assertEquals(gavin.getName(), "gavin");
    14
    assertEquals(gavin.getName(), "gavin");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.extralazy.Userorg.hibernate.test.map.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.map.User extend a common superclass
    14
    assertEquals(gavin.getName(), "gavin");
    15
    assertEquals(gavin.getSession().size(), 2);
    15
    assertEquals(gavin.getSession().size(), 2);
    15
    assertEquals(gavin.getSession().size(), 2);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.extralazy.Userorg.hibernate.test.map.UserVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.map.User extend a common superclass
    15
    assertEquals(gavin.getSession().size(), 2);
    16
    s.createQuery("delete SessionAttribute").executeUpdate();
    16
    s.createQuery("delete SessionAttribute").executeUpdate();
    17
    s.createQuery("delete User").executeUpdate();
    17
    s.createQuery("delete User").executeUpdate();
    18
    t.commit();
    18
    t.commit();
    19
    s.close();
    19
    s.close();
    Precondition Violations (10)
    Row Violation
    1Type org.hibernate.test.extralazy.SessionAttribute of variable new SessionAttribute("foo","foo bar baz") does not match with type org.hibernate.test.map.SessionAttribute of variable new SessionAttribute("foo","foo bar baz")
    2Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    3Type org.hibernate.test.extralazy.SessionAttribute of variable new SessionAttribute("bar","foo bar baz 2") does not match with type org.hibernate.test.map.SessionAttribute of variable new SessionAttribute("bar","foo bar baz 2")
    4Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    5Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    6Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.map.User of variable turin
    7Unmatched statement gavin=(User)((Object[])results.get(0))[0]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement gavin=(User)((Object[])results.get(0))[0]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin
    10Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.map.User of variable gavin