public void testOneToOnePropertyRef() { Session s = openSession(); Transaction t = s.beginTransaction(); Customer c = new Customer(); c.setName( "Emmanuel" ); c.setCustomerId( "C123-456" ); c.setPersonId( "P123-456" ); Account a = new Account(); a.setCustomer( c ); a.setPerson( c ); a.setType( 'X' ); s.persist( c ); s.persist( a ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" ) .uniqueResult(); assertNotNull( a.getCustomer() ); assertTrue( Hibernate.isInitialized( a.getCustomer() ) ); assertNotNull( a.getPerson() ); assertTrue( Hibernate.isInitialized( a.getPerson() ) ); c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult(); assertSame( c, a.getCustomer() ); assertSame( c, a.getPerson() ); s.delete( a ); s.delete( a.getCustomer() ); s.delete( a.getPerson() ); t.commit(); s.close();
public void testOneToOnePropertyRef() { Session s = openSession(); Transaction t = s.beginTransaction(); Customer c = new Customer(); c.setName( "Emmanuel" ); c.setCustomerId( "C123-456" ); c.setPersonId( "P123-456" ); Account a = new Account(); a.setCustomer( c ); a.setPerson( c ); a.setType( 'X' ); s.persist( c ); s.persist( a ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" ) .uniqueResult(); assertNotNull( a.getCustomer() ); assertTrue( Hibernate.isInitialized( a.getCustomer() ) ); assertNotNull( a.getPerson() ); assertTrue( Hibernate.isInitialized( a.getPerson() ) ); c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult(); assertSame( c, a.getCustomer() ); assertSame( c, a.getPerson() ); s.delete( a ); s.delete( a.getCustomer() ); s.delete( a.getPerson() ); 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/propertyref/inheritence/discrim/SubclassPropertyRefTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public void testOneToOnePropertyRef() {
1
public void testOneToOnePropertyRef() {
2
		Session s = openSession();
2
		Session s = openSession();
3
		Transaction t = s.beginTransaction();
3
		Transaction t = s.beginTransaction();
4
		Customer c = new Customer();
4
		Customer c = new Customer();
5
		c.setName( "Emmanuel" );
5
		c.setName( "Emmanuel" );
6
		c.setCustomerId( "C123-456" );
6
		c.setCustomerId( "C123-456" );
7
		c.setPersonId( "P123-456" );
7
		c.setPersonId( "P123-456" );
8
		Account a = new Account();
8
		Account a = new Account();
9
		a.setCustomer( c );
9
		a.setCustomer( c );
10
		a.setPerson( c );
10
		a.setPerson( c );
11
		a.setType( 'X' );
11
		a.setType( 'X' );
12
		s.persist( c );
12
		s.persist( c );
13
		s.persist( a );
13
		s.persist( a );
14
		t.commit();
14
		t.commit();
15
		s.close();
15
		s.close();
16
		s = openSession();
16
		s = openSession();
17
		t = s.beginTransaction();
17
		t = s.beginTransaction();
18
		a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
18
		a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
19
				.uniqueResult();
19
				.uniqueResult();
20
		assertNotNull( a.getCustomer() );
20
		assertNotNull( a.getCustomer() );
21
		assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
21
		assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
22
		assertNotNull( a.getPerson() );
22
		assertNotNull( a.getPerson() );
23
		assertTrue( Hibernate.isInitialized( a.getPerson() ) );
23
		assertTrue( Hibernate.isInitialized( a.getPerson() ) );
24
		c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
24
		c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
25
		assertSame( c, a.getCustomer() );
25
		assertSame( c, a.getCustomer() );
26
		assertSame( c, a.getPerson() );
26
		assertSame( c, a.getPerson() );
27
		s.delete( a );
27
		s.delete( a );
28
		s.delete( a.getCustomer() );
28
		s.delete( a.getCustomer() );
29
		s.delete( a.getPerson() );
29
		s.delete( a.getPerson() );
30
		t.commit();
30
		t.commit();
31
		s.close();
31
		s.close();
32
	
32
	
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