public class SubclassPropertyRefTest extends FunctionalTestCase { public SubclassPropertyRefTest(String name) { super( name ); } public String[] getMappings() { return new String[] { "propertyref/inheritence/discrim/Person.hbm.xml" }; } public static Test suite() { return new FunctionalTestClassTestSuite( SubclassPropertyRefTest.class ); } 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 class UnionSubclassPropertyRefTest extends FunctionalTestCase { public UnionSubclassPropertyRefTest(String name) { super( name ); } public String[] getMappings() { return new String[] { "propertyref/inheritence/union/Person.hbm.xml" }; } public static Test suite() { return new FunctionalTestClassTestSuite( UnionSubclassPropertyRefTest.class ); } 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 class SubclassPropertyRefTest extends FunctionalTestCase {
1
public class UnionSubclassPropertyRefTest extends FunctionalTestCase {
2
	public SubclassPropertyRefTest(String name) {
2
	public UnionSubclassPropertyRefTest(String name) {
3
		super( name );
3
		super( name );
4
	}
4
	}
5
	public String[] getMappings() {
5
	public String[] getMappings() {
6
		return new String[] { "propertyref/inheritence/discrim/Person.hbm.xml" };
6
		return new String[] { "propertyref/inheritence/union/Person.hbm.xml" };
7
	}
7
	}
8
	public static Test suite() {
8
	public static Test suite() {
9
		return new FunctionalTestClassTestSuite( SubclassPropertyRefTest.class );
9
		return new FunctionalTestClassTestSuite( UnionSubclassPropertyRefTest.class );
10
	}
10
	}
11
	public void testOneToOnePropertyRef() {
11
	public void testOneToOnePropertyRef() {
12
		Session s = openSession();
12
		Session s = openSession();
13
		Transaction t = s.beginTransaction();
13
		Transaction t = s.beginTransaction();
14
		Customer c = new Customer();
14
		Customer c = new Customer();
15
		c.setName( "Emmanuel" );
15
		c.setName( "Emmanuel" );
16
		c.setCustomerId( "C123-456" );
16
		c.setCustomerId( "C123-456" );
17
		c.setPersonId( "P123-456" );
17
		c.setPersonId( "P123-456" );
18
		Account a = new Account();
18
		Account a = new Account();
19
		a.setCustomer( c );
19
		a.setCustomer( c );
20
		a.setPerson( c );
20
		a.setPerson( c );
21
		a.setType( 'X' );
21
		a.setType( 'X' );
22
		s.persist( c );
22
		s.persist( c );
23
		s.persist( a );
23
		s.persist( a );
24
		t.commit();
24
		t.commit();
25
		s.close();
25
		s.close();
26
		s = openSession();
26
		s = openSession();
27
		t = s.beginTransaction();
27
		t = s.beginTransaction();
28
		a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
28
		a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
29
				.uniqueResult();
29
				.uniqueResult();
30
		assertNotNull( a.getCustomer() );
30
		assertNotNull( a.getCustomer() );
31
		assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
31
		assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
32
		assertNotNull( a.getPerson() );
32
		assertNotNull( a.getPerson() );
33
		assertTrue( Hibernate.isInitialized( a.getPerson() ) );
33
		assertTrue( Hibernate.isInitialized( a.getPerson() ) );
34
		c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
34
		c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
35
		assertSame( c, a.getCustomer() );
35
		assertSame( c, a.getCustomer() );
36
		assertSame( c, a.getPerson() );
36
		assertSame( c, a.getPerson() );
37
		s.delete( a );
37
		s.delete( a );
38
		s.delete( a.getCustomer() );
38
		s.delete( a.getCustomer() );
39
		s.delete( a.getPerson() );
39
		s.delete( a.getPerson() );
40
		t.commit();
40
		t.commit();
41
		s.close()
41
		s.close()
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