File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java | |||
Method name: void testComponentPropertyRef()
|
Method name: void testComponentPropertyRef()
|
|||
Number of AST nodes: 35 | Number of AST nodes: 35 | |||
1 | Person p = new Person();↵ | 1 | Person p = new Person();↵ | |
2 | p.setIdentity( new Identity() );↵ | 2 | p.setIdentity( new Identity() );↵ | |
3 | Account a = new Account();↵ | 3 | Account a = new Account();↵ | |
4 | a.setNumber("123-12345-1236");↵ | 4 | a.setNumber("123-12345-1236");↵ | |
5 | a.setOwner(p);↵ | 5 | a.setOwner(p);↵ | |
6 | p.getIdentity().setName("Gavin");↵ | 6 | p.getIdentity().setName("Gavin");↵ | |
7 | p.getIdentity().setSsn("123-12-1234");↵ | 7 | p.getIdentity().setSsn("123-12-1234");↵ | |
8 | Session s = openSession();↵ | 8 | Session s = openSession();↵ | |
9 | Transaction tx = s.beginTransaction();↵ | 9 | Transaction tx = s.beginTransaction();↵ | |
10 | s.persist(p);↵ | 10 | s.persist(p);↵ | |
11 | s.persist(a);↵ | 11 | s.persist(a);↵ | |
12 | s.flush();↵ | 12 | s.flush();↵ | |
13 | s.clear();↵ | 13 | s.clear();↵ | |
14 | ↵ | |||
15 | a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();↵ | 14 | a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();↵ | |
16 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | 15 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | |
17 | assertNotNull( a.getOwner() );↵ | 16 | assertNotNull( a.getOwner() );↵ | |
18 | assertEquals( "Gavin", a.getOwner().getIdentity().getName() );↵ | 17 | assertEquals( "Gavin", a.getOwner().getIdentity().getName() );↵ | |
19 | s.clear();↵ | 18 | s.clear();↵ | |
20 | ↵ | |||
21 | a = (Account) s.get(Account.class, "123-12345-1236");↵ | 19 | a = (Account) s.get(Account.class, "123-12345-1236");↵ | |
22 | assertFalse( Hibernate.isInitialized( a.getOwner() ) );↵ | 20 | assertFalse( Hibernate.isInitialized( a.getOwner() ) );↵ | |
23 | assertNotNull( a.getOwner() );↵ | 21 | assertNotNull( a.getOwner() );↵ | |
24 | assertEquals( "Gavin", a.getOwner().getIdentity().getName() );↵ | 22 | assertEquals( "Gavin", a.getOwner().getIdentity().getName() );↵ | |
25 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | 23 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | |
26 | ↵ | |||
27 | s.clear();↵ | 24 | s.clear();↵ | |
28 | ↵ | |||
29 | getSessions().evict(Account.class);↵ | 25 | getSessions().evict(Account.class);↵ | |
30 | getSessions().evict(Person.class);↵ | 26 | getSessions().evict(Person.class);↵ | |
31 | ↵ | |||
32 | a = (Account) s.get(Account.class, "123-12345-1236");↵ | 27 | a = (Account) s.get(Account.class, "123-12345-1236");↵ | |
33 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | 28 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | |
34 | assertNotNull( a.getOwner() );↵ | 29 | assertNotNull( a.getOwner() );↵ | |
35 | assertEquals( "Gavin", a.getOwner().getIdentity().getName() );↵ | 30 | assertEquals( "Gavin", a.getOwner().getIdentity().getName() );↵ | |
36 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | 31 | assertTrue( Hibernate.isInitialized( a.getOwner() ) );↵ | |
37 | ↵ | |||
38 | s.delete( a );↵ | 32 | s.delete( a );↵ | |
39 | s.delete( a.getOwner() );↵ | 33 | s.delete( a.getOwner() );↵ | |
40 | tx.commit();↵ | 34 | tx.commit();↵ | |
41 | s.close(); | 35 |
| |
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 | 249 |
Number of mapped statements | 35 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Person p = new Person(); | 1 | Person p = new Person(); | ||||||||||||||
2 | p.setIdentity(new Identity()); |
| 2 | p.setIdentity(new Identity()); | |||||||||||||
3 | Account a = new Account(); | 3 | Account a = new Account(); | ||||||||||||||
4 | a.setNumber("123-12345-1236"); | 4 | a.setNumber("123-12345-1236"); | ||||||||||||||
5 | a.setOwner(p); | 5 | a.setOwner(p); | ||||||||||||||
6 | p.getIdentity().setName("Gavin"); |
| 6 | p.getIdentity().setName("Gavin"); | |||||||||||||
7 | p.getIdentity().setSsn("123-12-1234"); |
| 7 | p.getIdentity().setSsn("123-12-1234"); | |||||||||||||
8 | Session s = openSession(); | 8 | Session s = openSession(); | ||||||||||||||
9 | Transaction tx = s.beginTransaction(); | 9 | Transaction tx = s.beginTransaction(); | ||||||||||||||
10 | s.persist(p); | 10 | s.persist(p); | ||||||||||||||
11 | s.persist(a); | 11 | s.persist(a); | ||||||||||||||
12 | s.flush(); | 12 | s.flush(); | ||||||||||||||
13 | s.clear(); | 13 | s.clear(); | ||||||||||||||
14 | a = (Account)s.createQuery("from Account a left join fetch a.owner").uniqueResult(); | 14 | a = (Account)s.createQuery("from Account a left join fetch a.owner").uniqueResult(); | ||||||||||||||
15 | assertTrue(Hibernate.isInitialized(a.getOwner())); | 15 | assertTrue(Hibernate.isInitialized(a.getOwner())); | ||||||||||||||
16 | assertNotNull(a.getOwner()); | 16 | assertNotNull(a.getOwner()); | ||||||||||||||
17 | assertEquals("Gavin", a.getOwner().getIdentity().getName()); |
| 17 | assertEquals("Gavin", a.getOwner().getIdentity().getName()); | |||||||||||||
18 | s.clear(); | 18 | s.clear(); | ||||||||||||||
19 | a = (Account)s.get(Account.class, "123-12345-1236"); | 19 | a = (Account)s.get(Account.class, "123-12345-1236"); | ||||||||||||||
20 | assertFalse(Hibernate.isInitialized(a.getOwner())); | 20 | assertFalse(Hibernate.isInitialized(a.getOwner())); | ||||||||||||||
21 | assertNotNull(a.getOwner()); | 21 | assertNotNull(a.getOwner()); | ||||||||||||||
22 | assertEquals("Gavin", a.getOwner().getIdentity().getName()); |
| 22 | assertEquals("Gavin", a.getOwner().getIdentity().getName()); | |||||||||||||
23 | assertTrue(Hibernate.isInitialized(a.getOwner())); | 23 | assertTrue(Hibernate.isInitialized(a.getOwner())); | ||||||||||||||
24 | s.clear(); | 24 | s.clear(); | ||||||||||||||
25 | getSessions().evict(Account.class); | 25 | getSessions().evict(Account.class); | ||||||||||||||
26 | getSessions().evict(Person.class); | 26 | getSessions().evict(Person.class); | ||||||||||||||
27 | a = (Account)s.get(Account.class, "123-12345-1236"); | 27 | a = (Account)s.get(Account.class, "123-12345-1236"); | ||||||||||||||
28 | assertTrue(Hibernate.isInitialized(a.getOwner())); | 28 | assertTrue(Hibernate.isInitialized(a.getOwner())); | ||||||||||||||
29 | assertNotNull(a.getOwner()); | 29 | assertNotNull(a.getOwner()); | ||||||||||||||
30 | assertEquals("Gavin", a.getOwner().getIdentity().getName()); |
| 30 | assertEquals("Gavin", a.getOwner().getIdentity().getName()); | |||||||||||||
31 | assertTrue(Hibernate.isInitialized(a.getOwner())); | 31 | assertTrue(Hibernate.isInitialized(a.getOwner())); | ||||||||||||||
32 | s.delete(a); | 32 | s.delete(a); | ||||||||||||||
33 | s.delete(a.getOwner()); | 33 | s.delete(a.getOwner()); | ||||||||||||||
34 | tx.commit(); | 34 | tx.commit(); | ||||||||||||||
35 | s.close(); | 35 | s.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.propertyref.component.partial.Identity of variable new Identity() does not match with type org.hibernate.test.propertyref.component.complete.Identity of variable new Identity() |
2 | Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Type org.hibernate.test.propertyref.component.partial.Identity of variable p.getIdentity() does not match with type org.hibernate.test.propertyref.component.complete.Identity of variable p.getIdentity() |
5 | Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Type org.hibernate.test.propertyref.component.partial.Identity of variable p.getIdentity() does not match with type org.hibernate.test.propertyref.component.complete.Identity of variable p.getIdentity() |
8 | Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() |
11 | Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() |
14 | Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() |