public void testComponentPropertyRef() { Person p = new Person(); p.setIdentity( new Identity() ); Account a = new Account(); a.setNumber("123-12345-1236"); a.setOwner(p); p.getIdentity().setName("Gavin"); p.getIdentity().setSsn("123-12-1234"); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist(p); s.persist(a); s.flush(); s.clear(); a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult(); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); s.clear(); a = (Account) s.get(Account.class, "123-12345-1236"); assertFalse( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.clear(); getSessions().evict(Account.class); getSessions().evict(Person.class); a = (Account) s.get(Account.class, "123-12345-1236"); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.delete( a ); s.delete( a.getOwner() ); tx.commit(); s.close();
public void testComponentPropertyRef() { Person p = new Person(); p.setIdentity( new Identity() ); Account a = new Account(); a.setNumber("123-12345-1236"); a.setOwner(p); p.getIdentity().setName("Gavin"); p.getIdentity().setSsn("123-12-1234"); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist(p); s.persist(a); s.flush(); s.clear(); a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult(); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); s.clear(); a = (Account) s.get(Account.class, "123-12345-1236"); assertFalse( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.clear(); getSessions().evict(Account.class); getSessions().evict(Person.class); a = (Account) s.get(Account.class, "123-12345-1236"); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.delete( a ); s.delete( a.getOwner() ); tx.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/propertyref/component/complete/CompleteComponentPropertyRefTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public void testComponentPropertyRef() {
1
public void testComponentPropertyRef() {
2
		Person p = new Person();
2
		Person p = new Person();
3
		p.setIdentity( new Identity() );
3
		p.setIdentity( new Identity() );
4
		Account a = new Account();
4
		Account a = new Account();
5
		a.setNumber("123-12345-1236");
5
		a.setNumber("123-12345-1236");
6
		a.setOwner(p);
6
		a.setOwner(p);
7
		p.getIdentity().setName("Gavin");
7
		p.getIdentity().setName("Gavin");
8
		p.getIdentity().setSsn("123-12-1234");
8
		p.getIdentity().setSsn("123-12-1234");
9
		Session s = openSession();
9
		Session s = openSession();
10
		Transaction tx = s.beginTransaction();
10
		Transaction tx = s.beginTransaction();
11
		s.persist(p);
11
		s.persist(p);
12
		s.persist(a);
12
		s.persist(a);
13
		s.flush();
13
		s.flush();
14
		s.clear();
14
		s.clear();
15
		
15
		a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
16
		a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
16
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
17
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
17
		assertNotNull( a.getOwner() );
18
		assertNotNull( a.getOwner() );
18
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
19
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
19
		s.clear();
20
		s.clear();
21
		
20
		a = (Account) s.get(Account.class, "123-12345-1236");
22
		a = (Account) s.get(Account.class, "123-12345-1236");
21
		assertFalse( Hibernate.isInitialized( a.getOwner() ) );
23
		assertFalse( Hibernate.isInitialized( a.getOwner() ) );
22
		assertNotNull( a.getOwner() );
24
		assertNotNull( a.getOwner() );
23
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
25
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
24
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
26
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
27
		
25
		s.clear();
28
		s.clear();
29
		
26
		getSessions().evict(Account.class);
30
		getSessions().evict(Account.class);
27
		getSessions().evict(Person.class);
31
		getSessions().evict(Person.class);
32
		
28
		a = (Account) s.get(Account.class, "123-12345-1236");
33
		a = (Account) s.get(Account.class, "123-12345-1236");
29
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
34
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
30
		assertNotNull( a.getOwner() );
35
		assertNotNull( a.getOwner() );
31
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
36
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
32
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
37
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
38
		
33
		s.delete( a );
39
		s.delete( a );
34
		s.delete( a.getOwner() );
40
		s.delete( a.getOwner() );
35
		tx.commit();
41
		tx.commit();
36
		s.close();
42
		s.close();
37
	
43
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0