1
package org.hibernate.test.propertyref.inheritence.union;
3
import junit.framework.Test;
5
import org.hibernate.Hibernate;
6
import org.hibernate.Session;
7
import org.hibernate.Transaction;
8
import org.hibernate.junit.functional.FunctionalTestCase;
9
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
14
public class UnionSubclassPropertyRefTest extends FunctionalTestCase {
16
public UnionSubclassPropertyRefTest(String name) {
20
public String[] getMappings() {
21
return new String[] { "propertyref/inheritence/union/Person.hbm.xml" };
24
public static Test suite() {
25
return new FunctionalTestClassTestSuite( UnionSubclassPropertyRefTest.class );
28
public void testOneToOnePropertyRef() {
29
Session s = openSession();
30
Transaction t = s.beginTransaction();
31
Customer c = new Customer();
32
c.setName( "Emmanuel" );
33
c.setCustomerId( "C123-456" );
34
c.setPersonId( "P123-456" );
35
Account a = new Account();
45
t = s.beginTransaction();
46
a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
48
assertNotNull( a.getCustomer() );
49
assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
50
assertNotNull( a.getPerson() );
51
assertTrue( Hibernate.isInitialized( a.getPerson() ) );
52
c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
53
assertSame( c, a.getCustomer() );
54
assertSame( c, a.getPerson() );
56
s.delete( a.getCustomer() );
57
s.delete( a.getPerson() );