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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 677 |
Number of mapped statements | 22 |
Number of unmapped statements in the first code fragment | 15 |
Number of unmapped statements in the second code fragment | 13 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
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"); | ||||||||||||||||||||||
3 | User gavin = new User("gavin", "secret"); |
| | ||||||||||||||||||||||
|
| 4 | Person p2 = new Person("Emmanuel"); | ||||||||||||||||||||||
4 | User turin = new User("turin", "tiger"); |
| | ||||||||||||||||||||||
|
| 5 | Employee e = new Employee(p); | ||||||||||||||||||||||
5 | Group g = new Group("developers"); |
| | ||||||||||||||||||||||
| 6 | new Employment(e, "JBoss"); | |||||||||||||||||||||||
6 | g.getUsers().put("gavin", gavin); | | |||||||||||||||||||||||
|
| 7 | Employment old = new Employment(e, "IFA"); | ||||||||||||||||||||||
7 | g.getUsers().put("turin", turin); | | |||||||||||||||||||||||
|
| 8 | old.setEndDate(new Date()); | ||||||||||||||||||||||
|
| 9 | s.persist(p); | ||||||||||||||||||||||
8 | s.persist(g); |
| 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(); | ||||||||||||||||||||||
15 | g = (Group)s.get(Group.class, "developers"); |
| | ||||||||||||||||||||||
16 | gavin = (User)g.getUsers().get("gavin"); | | |||||||||||||||||||||||
17 | turin = (User)g.getUsers().get("turin"); | | |||||||||||||||||||||||
18 | assertFalse(Hibernate.isInitialized(g.getUsers())); |
| 16 | assertSame(p.getEmployee().getPerson(), p); | |||||||||||||||||||||
|
| 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())); |
| 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"); |
| | ||||||||||||||||||||||
28 | assertTrue(g.getUsers().isEmpty()); |
| 17 | assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())); | |||||||||||||||||||||
|
| 25 | p = (Person)s.get(Person.class, "Gavin"); | ||||||||||||||||||||||
29 | assertFalse(Hibernate.isInitialized(g.getUsers())); |
| 26 | assertSame(p.getEmployee().getPerson(), p); | |||||||||||||||||||||
30 | gavin = (User)s.get(User.class, "gavin"); |
| | ||||||||||||||||||||||
31 | assertFalse(gavin.getSession().containsKey("foo")); |
| 27 | assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())); | |||||||||||||||||||||
32 | assertFalse(Hibernate.isInitialized(gavin.getSession())); |
| 18 | assertEquals(p.getEmployee().getEmployments().size(), 1); | |||||||||||||||||||||
|
| 29 | p2 = (Person)s.get(Person.class, "Emmanuel"); | ||||||||||||||||||||||
| 30 | assertNull(p2.getEmployee()); | |||||||||||||||||||||||
33 | s.delete(gavin); |
| 33 | s.delete(p); | |||||||||||||||||||||
34 | s.delete(turin); |
| 32 | s.delete(old); | |||||||||||||||||||||
35 | s.delete(g); |
| 31 | s.delete(p2); | |||||||||||||||||||||
36 | t.commit(); | 34 | t.commit(); | ||||||||||||||||||||||
37 | s.close(); | 35 | s.close(); |
Row | Violation |
---|---|
1 | 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 |
2 | 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 |
3 | 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 | 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 | 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 |
6 | 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 |
7 | 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 |
8 | Unmatched statement old.setEndDate(new Date()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
9 | 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 |
10 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.lazyonetoone.Person of variable p2 |
11 | 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 |
12 | 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 |
13 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized |
16 | Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized |
17 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized |
20 | Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized |
21 | 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 |
22 | Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized |
25 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized |
26 | Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression assertTrue(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized |
29 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized |
30 | 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 |
31 | Expression g.getUsers().isEmpty() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
32 | Expression Hibernate.isInitialized(p.getEmployee().getEmployments()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
33 | 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 |
34 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
35 | Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
36 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized |
37 | Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized |
38 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
39 | Expression assertSame(p.getEmployee().getPerson(),p) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
40 | Expression assertFalse(Hibernate.isInitialized(g.getUsers())) is a void method call, and thus it cannot be parameterized |
41 | Expression assertSame(p.getEmployee().getPerson(),p) is a void method call, and thus it cannot be parameterized |
42 | 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 |
43 | Expression gavin.getSession().containsKey("foo") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
44 | Expression Hibernate.isInitialized(p.getEmployee().getEmployments()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
45 | Expression assertFalse(gavin.getSession().containsKey("foo")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
46 | Expression assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
47 | Expression assertFalse(gavin.getSession().containsKey("foo")) is a void method call, and thus it cannot be parameterized |
48 | Expression assertTrue(Hibernate.isInitialized(p.getEmployee().getEmployments())) is a void method call, and thus it cannot be parameterized |
49 | Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
50 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
51 | Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized |
52 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized |
53 | Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
54 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
55 | Expression assertFalse(Hibernate.isInitialized(gavin.getSession())) is a void method call, and thus it cannot be parameterized |
56 | Expression assertEquals(p.getEmployee().getEmployments().size(),1) is a void method call, and thus it cannot be parameterized |
57 | 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 |
58 | Type org.hibernate.test.extralazy.User of variable gavin does not match with type org.hibernate.test.lazyonetoone.Person of variable p |
59 | Type org.hibernate.test.extralazy.User of variable turin does not match with type org.hibernate.test.lazyonetoone.Employment of variable old |
60 | Type org.hibernate.test.extralazy.Group of variable g does not match with type org.hibernate.test.lazyonetoone.Person of variable p2 |