Session s = openSession(); Transaction t = s.beginTransaction(); User gavin = new User("gavin", "secret"); User turin = new User("turin", "tiger"); Group g = new Group("developers"); g.getUsers().put("gavin", gavin); g.getUsers().put("turin", turin); s.persist(g); gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") ); gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); g = (Group) s.get(Group.class, "developers"); gavin = (User) g.getUsers().get("gavin"); turin = (User) g.getUsers().get("turin"); assertFalse( Hibernate.isInitialized( g.getUsers() ) ); g.getUsers().clear(); gavin.getSession().remove("foo"); assertTrue( Hibernate.isInitialized( g.getUsers() ) ); assertTrue( Hibernate.isInitialized( gavin.getSession() ) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); g = (Group) s.get(Group.class, "developers"); assertTrue( g.getUsers().isEmpty() ); assertFalse( Hibernate.isInitialized( g.getUsers() ) ); gavin = (User) s.get(User.class, "gavin"); assertFalse( gavin.getSession().containsKey("foo") ); assertFalse( Hibernate.isInitialized( gavin.getSession() ) ); s.delete(gavin); s.delete(turin); s.delete(g); t.commit(); s.close();
Session s = openSession(); Transaction t = s.beginTransaction(); Person p = new Person("Gavin"); Person p2 = new Person("Emmanuel"); Employee e = new Employee(p); new Employment(e, "JBoss"); Employment old = new Employment(e, "IFA"); old.setEndDate( new Date() ); s.persist(p); s.persist(p2); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); p = (Person) s.createQuery("from Person where name='Gavin'").uniqueResult(); //assertFalse( Hibernate.isPropertyInitialized(p, "employee") ); assertSame( p.getEmployee().getPerson(), p ); assertTrue( Hibernate.isInitialized( p.getEmployee().getEmployments() ) ); assertEquals( p.getEmployee().getEmployments().size(), 1 ); p2 = (Person) s.createQuery("from Person where name='Emmanuel'").uniqueResult(); assertNull( p2.getEmployee() ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); p = (Person) s.get(Person.class, "Gavin"); //assertFalse( Hibernate.isPropertyInitialized(p, "employee") ); assertSame( p.getEmployee().getPerson(), p ); assertTrue( Hibernate.isInitialized( p.getEmployee().getEmployments() ) ); assertEquals( p.getEmployee().getEmployments().size(), 1 ); p2 = (Person) s.get(Person.class, "Emmanuel"); assertNull( p2.getEmployee() ); s.delete(p2); s.delete(old); s.delete(p); 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/lazyonetoone/LazyOneToOneTest.java
Method name: void testRemoveClear() Method name: void testLazy()
Number of AST nodes: 37 Number of AST nodes: 35
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
		Person p = new Person("Gavin"
4
		User turin = new User("turin", "tiger");
5
		Group g = new Group("developers");
6
		g.getUsers().put("gavin", gavin);
7
		g.getUsers().put("turin", turin);
8
		s.persist(g);
9
		gavin.getSession().put( "foo", new SessionAttribute("foo", "foo bar baz") );
10
		gavin.getSession().put( "bar", new SessionAttribute("bar", "foo bar baz 2") 
4
);
5
		Person p2 = new Person("Emmanuel");
6
		Employee e = new Employee(p);
7
		new Employment(e, "JBoss");
8
		Employment old = new Employment(e, "IFA");
9
		old.setEndDate( new Date() );
10
		s.persist(p);
11
);
11
		s.persist(p2);
12
		t.commit();
12
		t.commit();
13
		s.close();
13
		s.close();
14
		
14
		s = openSession();
15
		s = openSession();
15
		t = s.beginTransaction();
16
		t = s.beginTransaction();
16
		g = (Group) s.get(Group.class, "developers");
17
		p = (
17
		gavin = (User) g.getUsers().get("gavin");
18
Person) s.createQuery("from Person where name='Gavin'")
18
		turin = (User) g.getUsers().get("turin");
19
.uniqueResult();
19
		assertFalse( Hibernate.isInitialized( g.getUsers() ) );
20
		//assertFalse( Hibernate.isPropertyInitialized(
20
		g.getUsers().clear();
21
		gavin.getSession().remove("foo"
21
p, "employee") );
22
);
22
		assertSame( p.getEmployee().getPerson(), p );
23
		assertTrue( Hibernate.isInitialized( g.getUsers() ) );
23
		assertTrue( Hibernate.isInitialized( 
24
		assertTrue( Hibernate.isInitialized( gavin.getSession() 
24
p.getEmployee().getEmployments() ) );
25
		assertEquals( p.getEmployee().getEmployments().size(), 1 );
26
		p2 = (Person) s.createQuery("from Person where name='Emmanuel'").uniqueResult();
25
) );
27
		assertNull( p2.getEmployee() );
26
		t.commit();
28
		t.commit();
27
		s.close();
29
		s.close();
28
		s = openSession();
30
		s = openSession();
29
		t = s.beginTransaction();
31
		t = s.beginTransaction();
30
		g = (Group) s.get(Group.class, "developers"
32
		p = (Person) s.get(Person.class, "Gavin");
31
);
33
		//assertFalse( Hibernate.isPropertyInitialized(p, "employee") );
32
		assertTrue( g.getUsers().isEmpty() );
34
		assertSame( p.getEmployee().getPerson(), p );
33
		assertFalse( Hibernate.isInitialized( g.getUsers() ) );
35
		assertTrue( Hibernate.isInitialized( 
34
		gavin = (User) s.get(User.class, "gavin");
35
		assertFalse( gavin.getSession().containsKey("foo") );
36
		assertFalse( Hibernate.isInitialized( gavin.getSession() 
36
p.getEmployee().getEmployments() ) );
37
		assertEquals( p.getEmployee().getEmployments().size(), 1 );
38
		p2 = (Person) s.get(Person.class, "Emmanuel");
37
) );
39
		assertNull( p2.getEmployee() );
38
		s.delete(gavin);
40
		s.delete(p2);
39
		s.delete(turin);
41
		s.delete(old);
40
		s.delete(g);
42
		s.delete(p);
41
		t.commit();
43
		t.commit();
42
		s.close();
44
		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 comparisons677
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements22
    Number of unmapped statements in the first code fragment15
    Number of unmapped statements in the second code fragment13
    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();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
                                                                    
    3
    Person p = new Person("Gavin");
    Preondition Violations
    Unmatched statement Person p=new Person("Gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    Person p = new Person("Gavin");
    3
    User gavin = new User("gavin", "secret");
    3
    User gavin = new User("gavin", "secret");
    Preondition Violations
    Unmatched statement User gavin=new User("gavin","secret"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                      
                                                                            
    4
    Person p2 = new Person("Emmanuel");
    Preondition Violations
    Unmatched statement Person p2=new Person("Emmanuel"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    Person p2 = new Person("Emmanuel");
    4
    User turin = new User("turin", "tiger");
    4
    User turin = new User("turin", "tiger");
    Preondition Violations
    Unmatched statement User turin=new User("turin","tiger"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                    
                                                                
    5
    Employee e = new Employee(p);
    Preondition Violations
    Unmatched statement Employee e=new Employee(p); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    Employee e = new Employee(p);
    5
    Group g = new Group("developers");
    5
    Group g = new Group("developers");
    Preondition Violations
    Unmatched statement Group g=new Group("developers"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                          
                                                              
    6
    new Employment(e, "JBoss");
    6
    g.getUsers().put("gavin", gavin);
                                                                          
                                                                                        
    7
    Employment old = new Employment(e, "IFA");
    Preondition Violations
    Unmatched statement Employment old=new Employment(e,"IFA"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7
    Employment old = new Employment(e, "IFA");
    7
    g.getUsers().put("turin", turin);
                                                                          
                                                                
    8
    old.setEndDate(new Date());
    Preondition Violations
    Unmatched statement old.setEndDate(new Date()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8
    old.setEndDate(new Date());
                                    
    9
    s.persist(p);
    Preondition Violations
    Unmatched statement s.persist(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    s.persist(p);
    8
    s.persist(g);
    8
    s.persist(g);
    10
    s.persist(p2);
    Differences
    Expression1Expression2Difference
    gp2VARIABLE_NAME_MISMATCH
    org.hibernate.test.extralazy.Grouporg.hibernate.test.lazyonetoone.PersonVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.lazyonetoone.Person of variable p2
    • Make classes org.hibernate.test.extralazy.Group and org.hibernate.test.lazyonetoone.Person extend a common superclass
    10
    s.persist(p2);
    9
    gavin.getSession().put("foo", new SessionAttribute("foo", "foo bar baz"));
                                                                                                                                                          
    10
    gavin.getSession().put("bar", new SessionAttribute("bar", "foo bar baz 2"));
                                                                                                                                                                
    11
    t.commit();
    11
    t.commit();
    12
    s.close();
    12
    s.close();
    13
    s = openSession();
    13
    s = openSession();
    14
    t = s.beginTransaction();
    14
    t = s.beginTransaction();
                                                                                                                                                              
    15
    p = (Person)s.createQuery("from Person where name='Gavin'").uniqueResult();
    Preondition Violations
    Unmatched statement p=(Person)s.createQuery("from Person where name='Gavin'").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    p = (Person)s.createQuery("from Person where name='Gavin'").uniqueResult();
    15
    g = (Group)s.get(Group.class, "developers");
    15
    g = (Group)s.get(Group.class, "developers");
    Preondition Violations
    Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                              
    16
    gavin = (User)g.getUsers().get("gavin");
                                                                                        
    17
    turin = (User)g.getUsers().get("turin");
                                                                                        
    18
    assertFalse(Hibernate.isInitialized(g.getUsers()));
    18
    assertFalse(Hibernate.isInitialized(g.getUsers()));
    16
    assertSame(p.getEmployee().getPerson(), p);
    Differences
    Expression1Expression2Difference
    assertFalseassertSameMETHOD_INVOCATION_NAME_MISMATCH
    assertFalse(Hibernate.isInitialized(g.getUsers()))assertSame(p.getEmployee().getPerson(),p)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    16
    assertSame(p.getEmployee().getPerson(), p);
                                                                                                                                                                      
    19
    p2 = (Person)s.createQuery("from Person where name='Emmanuel'").uniqueResult();
    Preondition Violations
    Unmatched statement p2=(Person)s.createQuery("from Person where name='Emmanuel'").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19
    p2 = (Person)s.createQuery("from Person where name='Emmanuel'").uniqueResult();
    19
    g.getUsers().clear();
                                                      
                                                                      
    20
    assertNull(p2.getEmployee());
    20
    gavin.getSession().remove("foo");
                                                                              
    21
    assertTrue(Hibernate.isInitialized(g.getUsers()));
                                                                                                                
    22
    assertTrue(Hibernate.isInitialized(gavin.getSession()));
    22
    assertTrue(Hibernate.isInitialized(gavin.getSession()));
    28
    assertEquals(p.getEmployee().getEmployments().size(), 1);
    Differences
    Expression1Expression2Difference
    assertTrueassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue(Hibernate.isInitialized(gavin.getSession()))assertEquals(p.getEmployee().getEmployments().size(),1)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    28
    assertEquals(p.getEmployee().getEmployments().size(), 1);
    23
    t.commit();
    21
    t.commit();
    24
    s.close();
    22
    s.close();
    25
    s = openSession();
    23
    s = openSession();
    26
    t = s.beginTransaction();
    24
    t = s.beginTransaction();
    27
    g = (Group)s.get(Group.class, "developers");
    27
    g = (Group)s.get(Group.class, "developers");
    Preondition Violations
    Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                              
    28
    assertTrue(g.getUsers().isEmpty());
    28
    assertTrue(g.getUsers().isEmpty());
    17
    assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments()));
    Differences
    Expression1Expression2Difference
    g.getUsers().isEmpty()Hibernate.isInitialized(p.getEmployee().getEmployments())TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression g.getUsers().isEmpty() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Hibernate.isInitialized(p.getEmployee().getEmployments()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17
    assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments()));
                                                                                        
    25
    p = (Person)s.get(Person.class, "Gavin");
    Preondition Violations
    Unmatched statement p=(Person)s.get(Person.class,"Gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25
    p = (Person)s.get(Person.class, "Gavin");
    29
    assertFalse(Hibernate.isInitialized(g.getUsers()));
    29
    assertFalse(Hibernate.isInitialized(g.getUsers()));
    26
    assertSame(p.getEmployee().getPerson(), p);
    Differences
    Expression1Expression2Difference
    assertFalseassertSameMETHOD_INVOCATION_NAME_MISMATCH
    assertFalse(Hibernate.isInitialized(g.getUsers()))assertSame(p.getEmployee().getPerson(),p)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    26
    assertSame(p.getEmployee().getPerson(), p);
    30
    gavin = (User)s.get(User.class, "gavin");
    30
    gavin = (User)s.get(User.class, "gavin");
    Preondition Violations
    Unmatched statement gavin=(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
                                                                                        
    31
    assertFalse(gavin.getSession().containsKey("foo"));
    31
    assertFalse(gavin.getSession().containsKey("foo"));
    27
    assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments()));
    Differences
    Expression1Expression2Difference
    gavin.getSession().containsKey("foo")Hibernate.isInitialized(p.getEmployee().getEmployments())TYPE_COMPATIBLE_REPLACEMENT
    assertFalseassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression gavin.getSession().containsKey("foo") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Hibernate.isInitialized(p.getEmployee().getEmployments()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(gavin.getSession().containsKey("foo")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(gavin.getSession().containsKey("foo")) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())) is a void method call, and thus it cannot be parameterized
    27
    assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments()));
    32
    assertFalse(Hibernate.isInitialized(gavin.getSession()));
    32
    assertFalse(Hibernate.isInitialized(gavin.getSession()));
    18
    assertEquals(p.getEmployee().getEmployments().size(), 1);
    Differences
    Expression1Expression2Difference
    assertFalseassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertFalse(Hibernate.isInitialized(gavin.getSession()))assertEquals(p.getEmployee().getEmployments().size(),1)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    18
    assertEquals(p.getEmployee().getEmployments().size(), 1);
                                                                                                
    29
    p2 = (Person)s.get(Person.class, "Emmanuel");
    Preondition Violations
    Unmatched statement p2=(Person)s.get(Person.class,"Emmanuel"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29
    p2 = (Person)s.get(Person.class, "Emmanuel");
                                                                      
    30
    assertNull(p2.getEmployee());
    33
    s.delete(gavin);
    33
    s.delete(gavin);
    33
    s.delete(p);
    Differences
    Expression1Expression2Difference
    gavinpVARIABLE_NAME_MISMATCH
    org.hibernate.test.extralazy.Userorg.hibernate.test.lazyonetoone.PersonVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.lazyonetoone.Person of variable p
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.lazyonetoone.Person extend a common superclass
    33
    s.delete(p);
    34
    s.delete(turin);
    34
    s.delete(turin);
    32
    s.delete(old);
    Differences
    Expression1Expression2Difference
    turinoldVARIABLE_NAME_MISMATCH
    org.hibernate.test.extralazy.Userorg.hibernate.test.lazyonetoone.EmploymentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.lazyonetoone.Employment of variable old
    • Make classes org.hibernate.test.extralazy.User and org.hibernate.test.lazyonetoone.Employment extend a common superclass
    32
    s.delete(old);
    35
    s.delete(g);
    35
    s.delete(g);
    31
    s.delete(p2);
    Differences
    Expression1Expression2Difference
    gp2VARIABLE_NAME_MISMATCH
    org.hibernate.test.extralazy.Grouporg.hibernate.test.lazyonetoone.PersonVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.lazyonetoone.Person of variable p2
    • Make classes org.hibernate.test.extralazy.Group and org.hibernate.test.lazyonetoone.Person extend a common superclass
    31
    s.delete(p2);
    36
    t.commit();
    34
    t.commit();
    37
    s.close();
    35
    s.close();
    Precondition Violations (60)
    Row Violation
    1Unmatched statement Person p=new Person("Gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement User gavin=new User("gavin","secret"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement Person p2=new Person("Emmanuel"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement User turin=new User("turin","tiger"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement Employee e=new Employee(p); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement Group g=new Group("developers"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement Employment old=new Employment(e,"IFA"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement old.setEndDate(new Date()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9Unmatched statement s.persist(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.lazyonetoone.Person of variable p2
    11Unmatched statement p=(Person)s.createQuery("from Person where name='Gavin'").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    16Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    17Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    20Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    21Unmatched statement p2=(Person)s.createQuery("from Person where name='Emmanuel'").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    25Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    26Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    29Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    30Unmatched statement g=(Group)s.get(Group.class,"developers"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    31Expression g.getUsers().isEmpty() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32Expression Hibernate.isInitialized(p.getEmployee().getEmployments()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33Unmatched statement p=(Person)s.get(Person.class,"Gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    34Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    35Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    36Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    37Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    38Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    39Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    40Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized
    41Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized
    42Unmatched statement gavin=(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
    43Expression gavin.getSession().containsKey("foo") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    44Expression Hibernate.isInitialized(p.getEmployee().getEmployments()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    45Expression assertFalse(gavin.getSession().containsKey("foo")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    46Expression assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    47Expression assertFalse(gavin.getSession().containsKey("foo")) is a void method call, and thus it cannot be parameterized
    48Expression assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())) is a void method call, and thus it cannot be parameterized
    49Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    50Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    51Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    52Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    53Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    54Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    55Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized
    56Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized
    57Unmatched statement p2=(Person)s.get(Person.class,"Emmanuel"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    58Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.lazyonetoone.Person of variable p
    59Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.lazyonetoone.Employment of variable old
    60Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.lazyonetoone.Person of variable p2