[hibernate-commits] Hibernate SVN: r10921 - in branches/Branch_3_2/Hibernate3: src/org/hibernate/cfg src/org/hibernate/mapping test/org/hibernate/test test/org/hibernate/test/propertyref test/org/hibernate/test/propertyref/basic test/org/hibernate/test/propertyref/component test/org/hibernate/test/propertyref/component/complete test/org/hibernate/test/propertyref/component/partial test/org/hibernate/test/propertyref/inheritence test/org/hibernate/test/propertyref/inheritence/discrim test/org/hibernate/test/propertyref/inheritence/joined test/org/hibernate/test/propertyref/inheritence/union

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Dec 5 09:39:23 EST 2006


Author: steve.ebersole at jboss.com
Date: 2006-12-05 09:39:12 -0500 (Tue, 05 Dec 2006)
New Revision: 10921

Added:
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefSuite.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Address.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Group.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Identity.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Mapping.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Identity.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Mapping.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Customer.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/BankAccount.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Customer.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
Removed:
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Account.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Address.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Group.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/
Modified:
   branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/HbmBinder.java
   branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/PersistentClass.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
Log:
HHH-2282 : PersistentClass propetty lookups and embedded composite identifiers;
consolidate property-ref tests

Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/HbmBinder.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/HbmBinder.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/HbmBinder.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -2397,7 +2397,7 @@
 					keyVal = collection.getOwner().getIdentifier();
 				}
 				else {
-					keyVal = (KeyValue) collection.getOwner().getProperty( propRef ).getValue();
+					keyVal = (KeyValue) collection.getOwner().getReferencedProperty( propRef ).getValue();
 				}
 				SimpleValue key = new DependantValue( collection.getCollectionTable(), keyVal );
 				key.setCascadeDeleteEnabled( "cascade"

Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/PersistentClass.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/PersistentClass.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/PersistentClass.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -33,7 +33,7 @@
 
 	private String className;
 	private String proxyInterfaceName;
-	
+
 	private String nodeName;
 
 	private String discriminatorValue;
@@ -115,7 +115,7 @@
 
 	abstract int nextSubclassId();
 	public abstract int getSubclassId();
-	
+
 	public boolean useDynamicUpdate() {
 		return dynamicUpdate;
 	}
@@ -187,11 +187,11 @@
 		}
 		return new JoinedIterator(iters);
 	}
-	
+
 	public Table getIdentityTable() {
 		return getRootTable();
 	}
-	
+
 	public Iterator getDirectSubclasses() {
 		return subclasses.iterator();
 	}
@@ -310,71 +310,90 @@
 	public void setSelectBeforeUpdate(boolean selectBeforeUpdate) {
 		this.selectBeforeUpdate = selectBeforeUpdate;
 	}
-	
+
+	/**
+	 * Build an iterator of properties which are "referenceable".
+	 *
+	 * @see #getReferencedProperty for a discussion of "referenceable"
+	 * @return The property iterator.
+	 */
 	public Iterator getReferenceablePropertyIterator() {
 		return getPropertyClosureIterator();
 	}
 
+	/**
+	 * Given a property path, locate the appropriate referenceable property reference.
+	 * <p/>
+	 * A referenceable property is a property  which can be a target of a foreign-key
+	 * mapping (an identifier or explcitly named in a property-ref).
+	 *
+	 * @param propertyPath The property path to resolve into a property reference.
+	 * @return The property reference (never null).
+	 * @throws MappingException If the property could not be found.
+	 */
 	public Property getReferencedProperty(String propertyPath) throws MappingException {
-		Iterator iter = getReferenceablePropertyIterator();
 		try {
-			return getRecursiveProperty( propertyPath, iter );
+			return getRecursiveProperty( propertyPath, getReferenceablePropertyIterator() );
 		}
-		catch (MappingException e) {
+		catch ( MappingException e ) {
 			throw new MappingException(
-					"property-ref not found: " + propertyPath +
-					"in entity: " + getEntityName(), e
-				);
+					"property-ref [" + propertyPath + "] not found on entity [" + getEntityName() + "]", e
+			);
 		}
 	}
 
 	public Property getRecursiveProperty(String propertyPath) throws MappingException {
-		Iterator iter = getPropertyIterator(); //  getReferenceablePropertyIterator();
-		if ( getIdentifierMapper() != null ) {
-			ArrayList iterators = new ArrayList(2);
-			iterators.add(iter);
-			iterators.add( getIdentifierMapper().getPropertyIterator() );
-			iter = new JoinedIterator( iterators );
-		}
 		try {
-			return getRecursiveProperty( propertyPath, iter );
+			return getRecursiveProperty( propertyPath, getPropertyIterator() );
 		}
-		catch (MappingException e) {
+		catch ( MappingException e ) {
 			throw new MappingException(
-					"property not found: " + propertyPath +
-					"in entity: " + getEntityName(), e
-				);
+					"property [" + propertyPath + "] not found on entity [" + getEntityName() + "]", e
+			);
 		}
 	}
 
 	private Property getRecursiveProperty(String propertyPath, Iterator iter) throws MappingException {
 		Property property = null;
-
-		StringTokenizer st = new StringTokenizer( propertyPath, ".", false);
+		StringTokenizer st = new StringTokenizer( propertyPath, ".", false );
 		try {
 			while ( st.hasMoreElements() ) {
-				String element = (String) st.nextElement();
-				if (property == null) {
+				final String element = ( String ) st.nextElement();
+				if ( property == null ) {
+					// we are processing the root of the prpertyPath, so we have the following
+					// considerations:
+					//		1) specifically account for identifier properties
+					//		2) specifically account for embedded composite-identifiers
+					// 		3) perform a normal property lookup
 					Property identifierProperty = getIdentifierProperty();
-					if ( identifierProperty != null
-							&& identifierProperty.getName().equals( StringHelper.root(element) ) ) {
+					if ( identifierProperty != null && identifierProperty.getName().equals( element ) ) {
+						// we have a mapped identifier property and the root of
+						// the incoming property path matched that identifier
+						// property
 						property = identifierProperty;
 					}
-					else {
+					else if ( identifierProperty == null && getIdentifier() != null && Component.class.isInstance( getIdentifier() ) ) {
+						// we have an embedded composite identifier
+						identifierProperty = getProperty( element, ( ( Component ) getIdentifier() ).getPropertyIterator() );
+						if ( identifierProperty != null ) {
+							// the root of the incoming property path matched one
+							// of the embedded composite identifier properties
+							property = identifierProperty;
+						}
+					}
+
+					if ( property == null ) {
 						property = getProperty( element, iter );
 					}
 				}
 				else {
 					//flat recursive algorithm
-					property  = ( (Component) property.getValue() ).getProperty(element);
+					property = ( ( Component ) property.getValue() ).getProperty( element );
 				}
 			}
 		}
-		catch (MappingException e) {
-			throw new MappingException(
-					"property not found: " + propertyPath +
-					"in entity: " + getEntityName(), e
-				);
+		catch ( MappingException e ) {
+			throw new MappingException( "property [" + propertyPath + "] not found on entity [" + getEntityName() + "]" );
 		}
 
 		return property;
@@ -387,7 +406,7 @@
 				return prop;
 			}
 		}
-		throw new MappingException("property not found: " + propertyName + " on entity " + getEntityName());
+		throw new MappingException( "property [" + propertyName + "] not found on entity [" + getEntityName() + "]" );
 	}
 
 	public Property getProperty(String propertyName) throws MappingException {
@@ -425,7 +444,7 @@
 		checkPropertyDuplication();
 		checkColumnDuplication();
 	}
-	
+
 	private void checkPropertyDuplication() throws MappingException {
 		HashSet names = new HashSet();
 		Iterator iter = getPropertyIterator();
@@ -459,7 +478,7 @@
 	public String toString() {
 		return getClass().getName() + '(' + getEntityName() + ')';
 	}
-	
+
 	public Iterator getJoinIterator() {
 		return joins.iterator();
 	}
@@ -497,16 +516,33 @@
 		return 0;
 	}
 
+	/**
+	 * Build an iterator over the properties defined on this class.  The returned
+	 * iterator only accounts for "normal" properties (i.e. non-identifier
+	 * properties).
+	 * <p/>
+	 * Differs from {@link #getUnjoinedPropertyIterator} in that the iterator
+	 * we return here will include properties defined as part of a join.
+	 *
+	 * @return An iterator over the "normal" properties.
+	 */
 	public Iterator getPropertyIterator() {
 		ArrayList iterators = new ArrayList();
 		iterators.add( properties.iterator() );
-		for ( int i=0; i<joins.size(); i++ ) {
-			Join join = (Join) joins.get(i);
+		for ( int i = 0; i < joins.size(); i++ ) {
+			Join join = ( Join ) joins.get( i );
 			iterators.add( join.getPropertyIterator() );
 		}
-		return new JoinedIterator(iterators);
+		return new JoinedIterator( iterators );
 	}
 
+	/**
+	 * Build an iterator over the properties defined on this class <b>which
+	 * are not defined as part of a join</b>.  As with {@link #getPropertyIterator},
+	 * the returned iterator only accounts for non-identifier properties.
+	 *
+	 * @return An iterator over the non-joined "normal" properties.
+	 */
 	public Iterator getUnjoinedPropertyIterator() {
 		return properties.iterator();
 	}
@@ -588,7 +624,7 @@
 	}
 
 	public abstract java.util.Set getSynchronizedTables();
-	
+
 	public void addSynchronizedTable(String table) {
 		synchronizedTables.add(table);
 	}
@@ -601,26 +637,26 @@
 		this.isAbstract = isAbstract;
 	}
 
-	protected void checkColumnDuplication(Set distinctColumns, Iterator columns) 
+	protected void checkColumnDuplication(Set distinctColumns, Iterator columns)
 	throws MappingException {
 		while ( columns.hasNext() ) {
 			Selectable columnOrFormula = (Selectable) columns.next();
 			if ( !columnOrFormula.isFormula() ) {
 				Column col = (Column) columnOrFormula;
 				if ( !distinctColumns.add( col.getName() ) ) {
-					throw new MappingException( 
+					throw new MappingException(
 							"Repeated column in mapping for entity: " +
 							getEntityName() +
 							" column: " +
-							col.getName() + 
+							col.getName() +
 							" (should be mapped with insert=\"false\" update=\"false\")"
 						);
 				}
 			}
 		}
 	}
-	
-	protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties) 
+
+	protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties)
 	throws MappingException {
 		while ( properties.hasNext() ) {
 			Property prop = (Property) properties.next();
@@ -635,15 +671,15 @@
 			}
 		}
 	}
-	
+
 	protected Iterator getNonDuplicatedPropertyIterator() {
 		return getUnjoinedPropertyIterator();
 	}
-	
+
 	protected Iterator getDiscriminatorColumnIterator() {
 		return EmptyIterator.INSTANCE;
 	}
-	
+
 	protected void checkColumnDuplication() {
 		HashSet cols = new HashSet();
 		if (getIdentifierMapper() == null ) {
@@ -661,17 +697,17 @@
 			checkPropertyColumnDuplication( cols, join.getPropertyIterator() );
 		}
 	}
-	
+
 	public abstract Object accept(PersistentClassVisitor mv);
-	
+
 	public String getNodeName() {
 		return nodeName;
 	}
-	
+
 	public void setNodeName(String nodeName) {
 		this.nodeName = nodeName;
 	}
-	
+
 	public boolean hasPojoRepresentation() {
 		return getClassName()!=null;
 	}
@@ -683,7 +719,7 @@
 	public boolean hasSubselectLoadableCollections() {
 		return hasSubselectLoadableCollections;
 	}
-	
+
 	public void setSubselectLoadableCollections(boolean hasSubselectCollections) {
 		this.hasSubselectLoadableCollections = hasSubselectCollections;
 	}

Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -22,7 +22,6 @@
 import org.hibernate.test.collection.CollectionSuite;
 import org.hibernate.test.component.ComponentTest;
 import org.hibernate.test.compositeelement.CompositeElementTest;
-import org.hibernate.test.comppropertyref.ComponentPropertyRefTest;
 import org.hibernate.test.connections.ConnectionsSuite;
 import org.hibernate.test.criteria.CriteriaQueryTest;
 import org.hibernate.test.cuk.CompositePropertyRefTest;
@@ -104,7 +103,7 @@
 import org.hibernate.test.orphan.OrphanIdRollbackTest;
 import org.hibernate.test.orphan.OrphanTest;
 import org.hibernate.test.pagination.PaginationTest;
-import org.hibernate.test.propertyref.PropertyRefTest;
+import org.hibernate.test.propertyref.PropertyRefSuite;
 import org.hibernate.test.proxy.ProxyTest;
 import org.hibernate.test.querycache.QueryCacheTest;
 import org.hibernate.test.readonly.ReadOnlyTest;
@@ -116,7 +115,6 @@
 import org.hibernate.test.subclassfilter.DiscrimSubclassFilterTest;
 import org.hibernate.test.subclassfilter.JoinedSubclassFilterTest;
 import org.hibernate.test.subclassfilter.UnionSubclassFilterTest;
-import org.hibernate.test.subclasspropertyref.SubclassPropertyRefTest;
 import org.hibernate.test.subselect.SubselectTest;
 import org.hibernate.test.subselectfetch.SubselectFetchTest;
 import org.hibernate.test.ternary.TernaryTest;
@@ -214,11 +212,8 @@
 			suite.addTest( org.hibernate.test.onetoone.singletable.OneToOneTest.suite() );
 			suite.addTest( org.hibernate.test.onetoonelink.OneToOneTest.suite() );
 			suite.addTest( OptimisticLockTest.suite() );
-			suite.addTest( PropertyRefTest.suite() );
-			suite.addTest( ComponentPropertyRefTest.suite() );
-			suite.addTest( org.hibernate.test.joineduid.PropertyRefTest.suite() );
+			suite.addTest( PropertyRefSuite.suite() );
 			suite.addTest( org.hibernate.test.orphan.PropertyRefTest.suite() );
-			suite.addTest( SubclassPropertyRefTest.suite() );
 			suite.addTest( NativeSqlSupportSuite.suite() );
 			suite.addTest( CriteriaQueryTest.suite() );
 			suite.addTest( SubselectTest.suite() );

Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Account.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Account.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -1,48 +0,0 @@
-//$Id$
-package org.hibernate.test.propertyref;
-
-/**
- * @author Gavin King
- */
-public class Account {
-	private String accountId;
-	private Person user;
-	private char type;
-	/**
-	 * @return Returns the user.
-	 */
-	public Person getUser() {
-		return user;
-	}
-	/**
-	 * @param user The user to set.
-	 */
-	public void setUser(Person user) {
-		this.user = user;
-	}
-	/**
-	 * @return Returns the accountId.
-	 */
-	public String getAccountId() {
-		return accountId;
-	}
-	/**
-	 * @param accountId The accountId to set.
-	 */
-	public void setAccountId(String accountId) {
-		this.accountId = accountId;
-	}
-	/**
-	 * @return Returns the type.
-	 */
-	public char getType() {
-		return type;
-	}
-	/**
-	 * @param type The type to set.
-	 */
-	public void setType(char type) {
-		this.type = type;
-	}
-
-}

Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Address.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Address.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Address.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -1,73 +0,0 @@
-//$Id$
-package org.hibernate.test.propertyref;
-
-/**
- * @author gavin
- */
-public class Address {
-	private Long id;
-	private String address;
-	private String zip;
-	private String country;
-	private Person person;
-	/**
-	 * @return Returns the id.
-	 */
-	public Long getId() {
-		return id;
-	}
-	/**
-	 * @param id The id to set.
-	 */
-	public void setId(Long id) {
-		this.id = id;
-	}
-	/**
-	 * @return Returns the person.
-	 */
-	public Person getPerson() {
-		return person;
-	}
-	/**
-	 * @param person The person to set.
-	 */
-	public void setPerson(Person person) {
-		this.person = person;
-	}
-	/**
-	 * @return Returns the address.
-	 */
-	public String getAddress() {
-		return address;
-	}
-	/**
-	 * @param address The address to set.
-	 */
-	public void setAddress(String address) {
-		this.address = address;
-	}
-	/**
-	 * @return Returns the country.
-	 */
-	public String getCountry() {
-		return country;
-	}
-	/**
-	 * @param country The country to set.
-	 */
-	public void setCountry(String country) {
-		this.country = country;
-	}
-	/**
-	 * @return Returns the zip.
-	 */
-	public String getZip() {
-		return zip;
-	}
-	/**
-	 * @param zip The zip to set.
-	 */
-	public void setZip(String zip) {
-		this.zip = zip;
-	}
-}

Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Group.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Group.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Group.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -1,23 +0,0 @@
-//$Id$
-package org.hibernate.test.propertyref;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class Group {
-	private String name;
-	private Set users = new HashSet();
-	
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-	public Set getUsers() {
-		return users;
-	}
-	public void setUsers(Set users) {
-		this.users = users;
-	}
-}

Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -1,81 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC 
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
-  Demonstrates the use of property-ref to map legacy data where
-  foreign keys reference something other than the primary key of
-  the associated entity. Here we show:
-  
-  (1) A one-to-one foreign key association (prefer primary key 
-      associations)
-      
-  (2) A bidirectional one-to-many association on a key that is
-      not the primary key (prefer associations from foreign keys
-      to primary keys)
-
--->
-
-<hibernate-mapping package="org.hibernate.test.propertyref">
-
-	<class name="Person">
-		
-		<id name="id">
-			<generator class="hilo"/>
-		</id>
-		
-		<property name="name" length="100"/>
-		
-		<one-to-one name="address" 
-			property-ref="person"
-			cascade="all"
-			fetch="join"/>
-		
-		<set name="accounts" 
-			inverse="true">
-			<key column="userId"
-				property-ref="userId"/>
-			<one-to-many class="Account"/>
-		</set>
-		
-		<property name="userId" column="person_userid" length="8" unique="true"/>
-	
-	</class>
-
-	<class name="Address">
-	
-		<id name="id">
-			<generator class="hilo"/>
-		</id>
-	
-		<property name="address" length="300"/>
-		<property name="zip" length="5"/>
-		<property name="country" length="25"/>
-		<many-to-one name="person" unique="true" not-null="true"/>
-	
-	</class>
-	
-	<class name="Account">
-		<id name="accountId" length="32">
-			<generator class="uuid.hex"/>
-		</id>
-		
-		<many-to-one name="user" 
-			column="userId"
-			property-ref="userId"/>
-		
-		<property name="type" not-null="true"/>
-		
-	</class>
-	
-	<class name="Group" table="`Group`">
-		<id name="name"/>
-		<set name="users" table="UserGroup" cascade="save-update">
-			<key column="groupName"/>
-			<many-to-many column="userId" class="Person" property-ref="userId"/>
-		</set>
-	</class>
-
-</hibernate-mapping>
\ No newline at end of file

Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -1,76 +0,0 @@
-//$Id$
-package org.hibernate.test.propertyref;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author gavin
- */
-public class Person {
-	private Long id;
-	private String name;
-	private Address address;
-	private String userId;
-	private Set accounts = new HashSet();
-	/**
-	 * @return Returns the userId.
-	 */
-	public String getUserId() {
-		return userId;
-	}
-	/**
-	 * @param userId The userId to set.
-	 */
-	public void setUserId(String userId) {
-		this.userId = userId;
-	}
-	/**
-	 * @return Returns the address.
-	 */
-	public Address getAddress() {
-		return address;
-	}
-	/**
-	 * @param address The address to set.
-	 */
-	public void setAddress(Address address) {
-		this.address = address;
-	}
-	/**
-	 * @return Returns the id.
-	 */
-	public Long getId() {
-		return id;
-	}
-	/**
-	 * @param id The id to set.
-	 */
-	public void setId(Long id) {
-		this.id = id;
-	}
-	/**
-	 * @return Returns the name.
-	 */
-	public String getName() {
-		return name;
-	}
-	/**
-	 * @param name The name to set.
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-	/**
-	 * @return Returns the accounts.
-	 */
-	public Set getAccounts() {
-		return accounts;
-	}
-	/**
-	 * @param accounts The accounts to set.
-	 */
-	public void setAccounts(Set accounts) {
-		this.accounts = accounts;
-	}
-}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefSuite.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefSuite.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,29 @@
+package org.hibernate.test.propertyref;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.propertyref.basic.PropertyRefTest;
+import org.hibernate.test.propertyref.component.complete.CompleteComponentPropertyRefTest;
+import org.hibernate.test.propertyref.component.partial.PartialComponentPropertyRefTest;
+import org.hibernate.test.propertyref.inheritence.discrim.SubclassPropertyRefTest;
+import org.hibernate.test.propertyref.inheritence.joined.JoinedSubclassPropertyRefTest;
+import org.hibernate.test.propertyref.inheritence.union.UnionSubclassPropertyRefTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class PropertyRefSuite {
+	public static Test suite() {
+		TestSuite suite = new TestSuite( "property-ref suite" );
+		suite.addTest( PropertyRefTest.suite() );
+		suite.addTest( CompleteComponentPropertyRefTest.suite() );
+		suite.addTest( PartialComponentPropertyRefTest.suite() );
+		suite.addTest( SubclassPropertyRefTest.suite() );
+		suite.addTest( JoinedSubclassPropertyRefTest.suite() );
+		suite.addTest( UnionSubclassPropertyRefTest.suite() );
+		return suite;
+	}
+}

Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -1,232 +0,0 @@
-//$Id$
-package org.hibernate.test.propertyref;
-
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.FetchMode;
-import org.hibernate.Hibernate;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.ForeignKey;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class PropertyRefTest extends TestCase {
-	
-	public PropertyRefTest(String str) {
-		super(str);
-	}
-	
-	public void testManyToManyPropertyRef() {
-		// prepare some test data relating to the Group->Person many-to-many association
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		Person p = new Person();
-		p.setName( "Steve" );
-		p.setUserId( "steve" );
-		s.persist( p );
-		Group g = new Group();
-		g.setName( "Admins" );
-		g.getUsers().add( p );
-		s.persist( g );
-		// force a flush and detachment here to test reattachment handling of the property-ref (HHH-1531)
-		t.commit();
-		s.close();
-
-		Person p2 = new Person();
-		p2.setName( "Max" );
-		p2.setUserId( "max" );
-		g.getUsers().add( p2 );
-
-		s = openSession();
-		t = s.beginTransaction();
-		s.update( g );
-		t.commit();
-		s.close();
-
-		// test retrieval of the group
-		s = openSession();
-		t = s.beginTransaction();
-		g = ( Group ) s.createQuery( "from Group g left join fetch g.users" ).uniqueResult();
-		assertTrue( Hibernate.isInitialized( g.getUsers() ) );
-		assertEquals( 2, g.getUsers().size() );
-		s.delete( g );
-		s.createQuery( "delete Person" ).executeUpdate();
-		t.commit();
-		s.close();
-	}
-	
-	public void testOneToOnePropertyRef() {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		Person p = new Person();
-		p.setName("Steve");
-		p.setUserId("steve");
-		Address a = new Address();
-		a.setAddress("Texas");
-		a.setCountry("USA");
-		p.setAddress(a);
-		a.setPerson(p);
-		s.save(p);
-		Person p2 = new Person();
-		p2.setName("Max");
-		p2.setUserId("max");
-		s.save(p2);
-		Account act = new Account();
-		act.setType('c');
-		act.setUser(p2);
-		p2.getAccounts().add(act);
-		s.save(act);
-		s.flush();
-		s.clear();
-		
-		p = (Person) s.get( Person.class, p.getId() ); //get address reference by outer join
-		p2 = (Person) s.get( Person.class, p2.getId() ); //get null address reference by outer join
-		assertNull( p2.getAddress() );
-		assertNotNull( p.getAddress() );
-		List l = s.createQuery("from Person").list(); //pull address references for cache
-		assertEquals( l.size(), 2 );
-		assertTrue( l.contains(p) && l.contains(p2) );
-		s.clear();
-		
-		l = s.createQuery("from Person p order by p.name").list(); //get address references by sequential selects
-		assertEquals( l.size(), 2 );
-		assertNull( ( (Person) l.get(0) ).getAddress() );
-		assertNotNull( ( (Person) l.get(1) ).getAddress() );
-		s.clear();
-		
-		l = s.createQuery("from Person p left join fetch p.address a order by a.country").list(); //get em by outer join
-		assertEquals( l.size(), 2 );
-		if ( ( (Person) l.get(0) ).getName().equals("Max") ) {
-			assertNull( ( (Person) l.get(0) ).getAddress() );
-			assertNotNull( ( (Person) l.get(1) ).getAddress() );
-		}
-		else {
-			assertNull( ( (Person) l.get(1) ).getAddress() );
-			assertNotNull( ( (Person) l.get(0) ).getAddress() );
-		}
-		s.clear();
-		
-		l = s.createQuery("from Person p left join p.accounts a").list();
-		for ( int i=0; i<2; i++ ) {
-			Object[] row = (Object[]) l.get(i);
-			Person px = (Person) row[0];
-			assertFalse( Hibernate.isInitialized( px.getAccounts() ) );
-			assertTrue( px.getAccounts().size()>0 || row[1]==null );
-		}
-		s.clear();
-
-		l = s.createQuery("from Person p left join fetch p.accounts a order by p.name").list();
-		Person p0 = (Person) l.get(0);
-		assertTrue( Hibernate.isInitialized( p0.getAccounts() ) );
-		assertEquals( p0.getAccounts().size(), 1 );
-		assertSame( ( (Account) p0.getAccounts().iterator().next() ).getUser(), p0 );
-		Person p1 = (Person) l.get(1);
-		assertTrue( Hibernate.isInitialized( p1.getAccounts() ) );
-		assertEquals( p1.getAccounts().size(), 0 );
-		s.clear();
-		Account acc = (Account) s.createQuery("from Account a left join fetch a.user").uniqueResult();
-		assertTrue( Hibernate.isInitialized(acc.getUser()) );
-		assertNotNull(acc.getUser());
-		assertTrue( acc.getUser().getAccounts().contains(acc) );
-		
-		s.createQuery("delete from Address").executeUpdate();
-		s.createQuery("delete from Account").executeUpdate(); // to not break constraint violation between Person and Account
-		s.createQuery("delete from Person").executeUpdate();
-		
-		t.commit();
-		s.close();
-	}
-
-	
-	public void testJoinFetchPropertyRef() {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		Person p = new Person();
-		p.setName("Steve");
-		p.setUserId("steve");
-		Address a = new Address();
-		a.setAddress("Texas");
-		a.setCountry("USA");
-		p.setAddress(a);
-		a.setPerson(p);
-		s.save(p);
-
-		s.flush();
-		s.clear();
-
-		getSessions().getStatistics().clear();
-
-		p = (Person) s.get( Person.class, p.getId() ); //get address reference by outer join
-		
-		assertTrue( Hibernate.isInitialized( p.getAddress() ) );
-		assertNotNull( p.getAddress() );
-        assertEquals( getSessions().getStatistics().getPrepareStatementCount(), 1 );
-        assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
-
-		s.clear();
-
-		getSessions().getStatistics().clear();
-
-		p = (Person) s.createCriteria(Person.class)
-			.setFetchMode("address", FetchMode.SELECT)
-			.uniqueResult(); //get address reference by select
-		
-		assertTrue( Hibernate.isInitialized( p.getAddress() ) );
-		assertNotNull( p.getAddress() );
-        assertEquals( getSessions().getStatistics().getPrepareStatementCount(), 2 );
-        assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
-
-		s.createQuery("delete from Address").executeUpdate();
-		s.createQuery("delete from Person").executeUpdate();
-		
-		t.commit();
-		s.close();
-	}
-
-	public void testForeignKeyCreation() {
-		PersistentClass classMapping = getCfg().getClassMapping("org.hibernate.test.propertyref.Account");
-		
-		Iterator foreignKeyIterator = classMapping.getTable().getForeignKeyIterator();
-		boolean found = false;
-		while ( foreignKeyIterator.hasNext() ) {
-			ForeignKey element = (ForeignKey) foreignKeyIterator.next();
-			if(element.getReferencedEntityName().equals(Person.class.getName() ) ) {
-				
-				if(!element.isReferenceToPrimaryKey() ) {
-					List referencedColumns = element.getReferencedColumns();
-					Column column = (Column) referencedColumns.get(0);
-					if(column.getName().equals("person_userid") ) {
-						found = true; // extend test to include the columns
-					}				
-				}
-			}
-		}
-		
-		assertTrue("Property ref foreign key not found",found);
-	}
-	
-	protected String[] getMappings() {
-		return new String[] { "propertyref/Person.hbm.xml" };
-	}
-
-	public static Test suite() {
-		return new TestSuite(PropertyRefTest.class);
-	}
-
-	protected void configure(Configuration cfg) {
-		cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
-		cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
-	}
-}
-

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Account.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Account.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Account.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,48 @@
+//$Id$
+package org.hibernate.test.propertyref.basic;
+
+/**
+ * @author Gavin King
+ */
+public class Account {
+	private String accountId;
+	private Person user;
+	private char type;
+	/**
+	 * @return Returns the user.
+	 */
+	public Person getUser() {
+		return user;
+	}
+	/**
+	 * @param user The user to set.
+	 */
+	public void setUser(Person user) {
+		this.user = user;
+	}
+	/**
+	 * @return Returns the accountId.
+	 */
+	public String getAccountId() {
+		return accountId;
+	}
+	/**
+	 * @param accountId The accountId to set.
+	 */
+	public void setAccountId(String accountId) {
+		this.accountId = accountId;
+	}
+	/**
+	 * @return Returns the type.
+	 */
+	public char getType() {
+		return type;
+	}
+	/**
+	 * @param type The type to set.
+	 */
+	public void setType(char type) {
+		this.type = type;
+	}
+
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Account.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Address.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Address.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Address.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Address.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,73 @@
+//$Id$
+package org.hibernate.test.propertyref.basic;
+
+/**
+ * @author gavin
+ */
+public class Address {
+	private Long id;
+	private String address;
+	private String zip;
+	private String country;
+	private Person person;
+	/**
+	 * @return Returns the id.
+	 */
+	public Long getId() {
+		return id;
+	}
+	/**
+	 * @param id The id to set.
+	 */
+	public void setId(Long id) {
+		this.id = id;
+	}
+	/**
+	 * @return Returns the person.
+	 */
+	public Person getPerson() {
+		return person;
+	}
+	/**
+	 * @param person The person to set.
+	 */
+	public void setPerson(Person person) {
+		this.person = person;
+	}
+	/**
+	 * @return Returns the address.
+	 */
+	public String getAddress() {
+		return address;
+	}
+	/**
+	 * @param address The address to set.
+	 */
+	public void setAddress(String address) {
+		this.address = address;
+	}
+	/**
+	 * @return Returns the country.
+	 */
+	public String getCountry() {
+		return country;
+	}
+	/**
+	 * @param country The country to set.
+	 */
+	public void setCountry(String country) {
+		this.country = country;
+	}
+	/**
+	 * @return Returns the zip.
+	 */
+	public String getZip() {
+		return zip;
+	}
+	/**
+	 * @param zip The zip to set.
+	 */
+	public void setZip(String zip) {
+		this.zip = zip;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Address.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Group.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Group.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Group.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Group.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,23 @@
+//$Id$
+package org.hibernate.test.propertyref.basic;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Group {
+	private String name;
+	private Set users = new HashSet();
+	
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public Set getUsers() {
+		return users;
+	}
+	public void setUsers(Set users) {
+		this.users = users;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Group.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+  Demonstrates the use of property-ref to map legacy data where
+  foreign keys reference something other than the primary key of
+  the associated entity. Here we show:
+  
+  (1) A one-to-one foreign key association (prefer primary key 
+      associations)
+      
+  (2) A bidirectional one-to-many association on a key that is
+      not the primary key (prefer associations from foreign keys
+      to primary keys)
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.propertyref.basic">
+
+    <class name="Person" table="PROPREF_PERS">
+        <id name="id">
+            <generator class="hilo"/>
+        </id>
+        <property name="name" length="100"/>
+        <property name="userId" column="person_userid" length="8" unique="true"/>
+        <one-to-one name="address" property-ref="person" cascade="all" fetch="join"/>
+        <set name="accounts" inverse="true">
+            <key column="userId" property-ref="userId"/>
+            <one-to-many class="Account"/>
+        </set>
+    </class>
+
+    <class name="Address" table="PROPREF_ADDR">
+        <id name="id">
+            <generator class="hilo"/>
+        </id>
+        <property name="address" length="300"/>
+        <property name="zip" length="5"/>
+        <property name="country" length="25"/>
+        <many-to-one name="person" unique="true" not-null="true"/>
+    </class>
+
+    <class name="Account" table="PROPREF_ACCT">
+        <id name="accountId" length="32">
+            <generator class="uuid.hex"/>
+        </id>
+        <many-to-one name="user" column="userId" property-ref="userId"/>
+        <property name="type" not-null="true"/>
+    </class>
+
+    <class name="Group" table="PROPREF_GRP">
+        <id name="name"/>
+        <set name="users" table="PROPREF_USERGROUP" cascade="save-update">
+            <key column="groupName"/>
+            <many-to-many column="userId" class="Person" property-ref="userId"/>
+        </set>
+    </class>
+
+</hibernate-mapping>
\ No newline at end of file


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/Person.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,76 @@
+//$Id$
+package org.hibernate.test.propertyref.basic;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author gavin
+ */
+public class Person {
+	private Long id;
+	private String name;
+	private Address address;
+	private String userId;
+	private Set accounts = new HashSet();
+	/**
+	 * @return Returns the userId.
+	 */
+	public String getUserId() {
+		return userId;
+	}
+	/**
+	 * @param userId The userId to set.
+	 */
+	public void setUserId(String userId) {
+		this.userId = userId;
+	}
+	/**
+	 * @return Returns the address.
+	 */
+	public Address getAddress() {
+		return address;
+	}
+	/**
+	 * @param address The address to set.
+	 */
+	public void setAddress(Address address) {
+		this.address = address;
+	}
+	/**
+	 * @return Returns the id.
+	 */
+	public Long getId() {
+		return id;
+	}
+	/**
+	 * @param id The id to set.
+	 */
+	public void setId(Long id) {
+		this.id = id;
+	}
+	/**
+	 * @return Returns the name.
+	 */
+	public String getName() {
+		return name;
+	}
+	/**
+	 * @param name The name to set.
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+	/**
+	 * @return Returns the accounts.
+	 */
+	public Set getAccounts() {
+		return accounts;
+	}
+	/**
+	 * @param accounts The accounts to set.
+	 */
+	public void setAccounts(Set accounts) {
+		this.accounts = accounts;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,232 @@
+//$Id$
+package org.hibernate.test.propertyref.basic;
+
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.test.TestCase;
+
+/**
+ * @author Gavin King
+ */
+public class PropertyRefTest extends TestCase {
+	
+	public PropertyRefTest(String str) {
+		super(str);
+	}
+
+	protected String[] getMappings() {
+		return new String[] { "propertyref/basic/Person.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new TestSuite(PropertyRefTest.class);
+	}
+
+	protected void configure(Configuration cfg) {
+		cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
+		cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+	}
+	
+	public void testManyToManyPropertyRef() {
+		// prepare some test data relating to the Group->Person many-to-many association
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+		Person p = new Person();
+		p.setName( "Steve" );
+		p.setUserId( "steve" );
+		s.persist( p );
+		Group g = new Group();
+		g.setName( "Admins" );
+		g.getUsers().add( p );
+		s.persist( g );
+		// force a flush and detachment here to test reattachment handling of the property-ref (HHH-1531)
+		t.commit();
+		s.close();
+
+		Person p2 = new Person();
+		p2.setName( "Max" );
+		p2.setUserId( "max" );
+		g.getUsers().add( p2 );
+
+		s = openSession();
+		t = s.beginTransaction();
+		s.update( g );
+		t.commit();
+		s.close();
+
+		// test retrieval of the group
+		s = openSession();
+		t = s.beginTransaction();
+		g = ( Group ) s.createQuery( "from Group g left join fetch g.users" ).uniqueResult();
+		assertTrue( Hibernate.isInitialized( g.getUsers() ) );
+		assertEquals( 2, g.getUsers().size() );
+		s.delete( g );
+		s.createQuery( "delete Person" ).executeUpdate();
+		t.commit();
+		s.close();
+	}
+	
+	public void testOneToOnePropertyRef() {
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+		Person p = new Person();
+		p.setName("Steve");
+		p.setUserId("steve");
+		Address a = new Address();
+		a.setAddress("Texas");
+		a.setCountry("USA");
+		p.setAddress(a);
+		a.setPerson(p);
+		s.save(p);
+		Person p2 = new Person();
+		p2.setName("Max");
+		p2.setUserId("max");
+		s.save(p2);
+		Account act = new Account();
+		act.setType('c');
+		act.setUser(p2);
+		p2.getAccounts().add(act);
+		s.save(act);
+		s.flush();
+		s.clear();
+		
+		p = (Person) s.get( Person.class, p.getId() ); //get address reference by outer join
+		p2 = (Person) s.get( Person.class, p2.getId() ); //get null address reference by outer join
+		assertNull( p2.getAddress() );
+		assertNotNull( p.getAddress() );
+		List l = s.createQuery("from Person").list(); //pull address references for cache
+		assertEquals( l.size(), 2 );
+		assertTrue( l.contains(p) && l.contains(p2) );
+		s.clear();
+		
+		l = s.createQuery("from Person p order by p.name").list(); //get address references by sequential selects
+		assertEquals( l.size(), 2 );
+		assertNull( ( (Person) l.get(0) ).getAddress() );
+		assertNotNull( ( (Person) l.get(1) ).getAddress() );
+		s.clear();
+		
+		l = s.createQuery("from Person p left join fetch p.address a order by a.country").list(); //get em by outer join
+		assertEquals( l.size(), 2 );
+		if ( ( (Person) l.get(0) ).getName().equals("Max") ) {
+			assertNull( ( (Person) l.get(0) ).getAddress() );
+			assertNotNull( ( (Person) l.get(1) ).getAddress() );
+		}
+		else {
+			assertNull( ( (Person) l.get(1) ).getAddress() );
+			assertNotNull( ( (Person) l.get(0) ).getAddress() );
+		}
+		s.clear();
+		
+		l = s.createQuery("from Person p left join p.accounts a").list();
+		for ( int i=0; i<2; i++ ) {
+			Object[] row = (Object[]) l.get(i);
+			Person px = (Person) row[0];
+			assertFalse( Hibernate.isInitialized( px.getAccounts() ) );
+			assertTrue( px.getAccounts().size()>0 || row[1]==null );
+		}
+		s.clear();
+
+		l = s.createQuery("from Person p left join fetch p.accounts a order by p.name").list();
+		Person p0 = (Person) l.get(0);
+		assertTrue( Hibernate.isInitialized( p0.getAccounts() ) );
+		assertEquals( p0.getAccounts().size(), 1 );
+		assertSame( ( (Account) p0.getAccounts().iterator().next() ).getUser(), p0 );
+		Person p1 = (Person) l.get(1);
+		assertTrue( Hibernate.isInitialized( p1.getAccounts() ) );
+		assertEquals( p1.getAccounts().size(), 0 );
+		s.clear();
+		Account acc = (Account) s.createQuery("from Account a left join fetch a.user").uniqueResult();
+		assertTrue( Hibernate.isInitialized(acc.getUser()) );
+		assertNotNull(acc.getUser());
+		assertTrue( acc.getUser().getAccounts().contains(acc) );
+		
+		s.createQuery("delete from Address").executeUpdate();
+		s.createQuery("delete from Account").executeUpdate(); // to not break constraint violation between Person and Account
+		s.createQuery("delete from Person").executeUpdate();
+		
+		t.commit();
+		s.close();
+	}
+
+	
+	public void testJoinFetchPropertyRef() {
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+		Person p = new Person();
+		p.setName("Steve");
+		p.setUserId("steve");
+		Address a = new Address();
+		a.setAddress("Texas");
+		a.setCountry("USA");
+		p.setAddress(a);
+		a.setPerson(p);
+		s.save(p);
+
+		s.flush();
+		s.clear();
+
+		getSessions().getStatistics().clear();
+
+		p = (Person) s.get( Person.class, p.getId() ); //get address reference by outer join
+		
+		assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+		assertNotNull( p.getAddress() );
+        assertEquals( getSessions().getStatistics().getPrepareStatementCount(), 1 );
+        assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
+
+		s.clear();
+
+		getSessions().getStatistics().clear();
+
+		p = (Person) s.createCriteria(Person.class)
+			.setFetchMode("address", FetchMode.SELECT)
+			.uniqueResult(); //get address reference by select
+		
+		assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+		assertNotNull( p.getAddress() );
+        assertEquals( getSessions().getStatistics().getPrepareStatementCount(), 2 );
+        assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
+
+		s.createQuery("delete from Address").executeUpdate();
+		s.createQuery("delete from Person").executeUpdate();
+		
+		t.commit();
+		s.close();
+	}
+
+	public void testForeignKeyCreation() {
+		PersistentClass classMapping = getCfg().getClassMapping("org.hibernate.test.propertyref.basic.Account");
+		
+		Iterator foreignKeyIterator = classMapping.getTable().getForeignKeyIterator();
+		boolean found = false;
+		while ( foreignKeyIterator.hasNext() ) {
+			ForeignKey element = (ForeignKey) foreignKeyIterator.next();
+			if(element.getReferencedEntityName().equals(Person.class.getName() ) ) {
+				
+				if(!element.isReferenceToPrimaryKey() ) {
+					List referencedColumns = element.getReferencedColumns();
+					Column column = (Column) referencedColumns.get(0);
+					if(column.getName().equals("person_userid") ) {
+						found = true; // extend test to include the columns
+					}				
+				}
+			}
+		}
+		
+		assertTrue("Property ref foreign key not found",found);
+	}
+}
+


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Account.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Account.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,23 @@
+package org.hibernate.test.propertyref.component.complete;
+
+
+public class Account {
+	private String number;
+	private Person owner;
+
+	public Person getOwner() {
+		return owner;
+	}
+
+	public void setOwner(Person owner) {
+		this.owner = owner;
+	}
+
+	public String getNumber() {
+		return number;
+	}
+
+	public void setNumber(String number) {
+		this.number = number;
+	}
+}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,71 @@
+package org.hibernate.test.propertyref.component.complete;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.Hibernate;
+
+/**
+ * @author Gavin King
+ */
+public class CompleteComponentPropertyRefTest extends TestCase {
+
+	public CompleteComponentPropertyRefTest(String str) {
+		super(str);
+	}
+
+	protected String[] getMappings() {
+		return new String[] { "propertyref/component/complete/Mapping.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new TestSuite( CompleteComponentPropertyRefTest.class);
+	}
+
+	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();
+	}
+}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Identity.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Identity.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Identity.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,21 @@
+package org.hibernate.test.propertyref.component.complete;
+
+import java.io.Serializable;
+
+public class Identity implements Serializable {
+	private String name;
+	private String ssn;
+
+	public String getSsn() {
+		return ssn;
+	}
+	public void setSsn(String id) {
+		this.ssn = id;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Mapping.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Mapping.hbm.xml	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Mapping.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!-- 
+
+     
+-->
+
+<hibernate-mapping package="org.hibernate.test.propertyref.component.complete">
+	
+	<class name="Person" table="COMP_COMP_PROPREF_PERSON">
+		<id name="id">
+			<generator class="increment"/>
+		</id>
+		<component name="identity" class="Identity">
+			<property name="name"/>
+			<property name="ssn" unique="true"/>
+		</component>
+	</class>
+	
+	<class name="Account" table="COMP_COMP_PROPREF_ACCT">
+		<id name="number" column="accnum"/>
+		<many-to-one name="owner" property-ref="identity">
+            <column name="OWNER_NAME" />
+            <column name="OWNER_SSN" />
+        </many-to-one>
+	</class>
+
+</hibernate-mapping>

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Person.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Person.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,20 @@
+package org.hibernate.test.propertyref.component.complete;
+
+
+public class Person {
+	private Long id;
+	private Identity identity;
+	
+	public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public Identity getIdentity() {
+		return identity;
+	}
+	public void setIdentity(Identity identity) {
+		this.identity = identity;
+	}
+}

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Account.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/Account.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/Account.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,23 @@
+//$Id$
+package org.hibernate.test.propertyref.component.partial;
+
+public class Account {
+	private String number;
+	private Person owner;
+
+	public Person getOwner() {
+		return owner;
+	}
+
+	public void setOwner(Person owner) {
+		this.owner = owner;
+	}
+
+	public String getNumber() {
+		return number;
+	}
+
+	public void setNumber(String number) {
+		this.number = number;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Account.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Identity.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/Identity.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/Identity.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Identity.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,20 @@
+//$Id$
+package org.hibernate.test.propertyref.component.partial;
+
+public class Identity {
+	private String name;
+	private String ssn;
+	
+	public String getSsn() {
+		return ssn;
+	}
+	public void setSsn(String id) {
+		this.ssn = id;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Identity.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Mapping.hbm.xml (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/PersonAccount.hbm.xml)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/PersonAccount.hbm.xml	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Mapping.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!-- 
+
+     
+-->
+
+<hibernate-mapping package="org.hibernate.test.propertyref.component.partial">
+	
+	<class name="Person" table="PART_COMP_PROPREF_PERS">
+		<id name="id">
+			<generator class="increment"/>
+		</id>
+		<component name="identity">
+			<property name="name"/>
+			<property name="ssn" unique="true"/>
+		</component>
+	</class>
+	
+	<class name="Account" table="PART_COMP_PROPREF_ACCT">
+		<id name="number" column="accnum"/>
+		<many-to-one name="owner" property-ref="identity.ssn"/>
+	</class>
+
+</hibernate-mapping>


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Mapping.hbm.xml
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/ComponentPropertyRefTest.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/ComponentPropertyRefTest.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,73 @@
+//$Id$
+package org.hibernate.test.propertyref.component.partial;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.TestCase;
+
+/**
+ * @author Gavin King
+ */
+public class PartialComponentPropertyRefTest extends TestCase {
+	
+	public PartialComponentPropertyRefTest(String str) {
+		super(str);
+	}
+
+	protected String[] getMappings() {
+		return new String[] { "propertyref/component/partial/Mapping.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new TestSuite( PartialComponentPropertyRefTest.class);
+	}
+	
+	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();
+	}
+}
+


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Person.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/Person.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/comppropertyref/Person.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,20 @@
+//$Id$
+package org.hibernate.test.propertyref.component.partial;
+
+public class Person {
+	private Long id;
+	private Identity identity;
+	
+	public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public Identity getIdentity() {
+		return identity;
+	}
+	public void setIdentity(Identity identity) {
+		this.identity = identity;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/Person.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Account.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Account.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Account.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,57 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.discrim;
+
+/**
+ * @author Gavin King
+ */
+public class Account {
+	private String accountId;
+	private Customer customer;
+	private Person person;
+	private char type;
+	/**
+	 * @return Returns the user.
+	 */
+	public Customer getCustomer() {
+		return customer;
+	}
+	/**
+	 * @param user The user to set.
+	 */
+	public void setCustomer(Customer user) {
+		this.customer = user;
+	}
+	/**
+	 * @return Returns the accountId.
+	 */
+	public String getAccountId() {
+		return accountId;
+	}
+	/**
+	 * @param accountId The accountId to set.
+	 */
+	public void setAccountId(String accountId) {
+		this.accountId = accountId;
+	}
+	/**
+	 * @return Returns the type.
+	 */
+	public char getType() {
+		return type;
+	}
+	/**
+	 * @param type The type to set.
+	 */
+	public void setType(char type) {
+		this.type = type;
+	}
+	public Person getPerson() {
+		return person;
+	}
+	
+	public void setPerson(Person person) {
+		this.person = person;
+	}
+	
+
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Account.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Customer.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Customer.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Customer.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Customer.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,18 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.discrim;
+
+/**
+ * @author Gavin King
+ */
+public class Customer extends Person {
+	private String customerId;
+
+	public String getCustomerId() {
+		return customerId;
+	}
+	
+	public void setCustomerId(String customerId) {
+		this.customerId = customerId;
+	}
+	
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Customer.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.hbm.xml (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Person.hbm.xml)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Person.hbm.xml	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.propertyref.inheritence.discrim">
+
+	<class name="Person" discriminator-value="null" table="D_SBCLS_PROPREF_PERS">
+		<id name="id">
+			<generator class="hilo"/>
+		</id>
+		<discriminator formula="customerId"/>
+		<property name="name" length="100"/>
+		<property name="personId" length="8" unique="true"/>
+				
+		<subclass name="Customer" discriminator-value="not null">
+			<property name="customerId" length="8" unique="true"/>
+		</subclass>
+	</class>
+	
+	<class name="Account" table="D_SBCLS_PROPREF_ACCT">
+		<id name="accountId" length="32">
+			<generator class="uuid.hex"/>
+		</id>
+		<many-to-one name="person" column="personId" unique="true" property-ref="personId"/>
+		<many-to-one name="customer" column="customerPersonId" unique="true" property-ref="personId"/>
+		<property name="type" not-null="true"/>
+	</class>
+
+</hibernate-mapping>
\ No newline at end of file


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.hbm.xml
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Person.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/Person.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,44 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.discrim;
+
+
+/**
+ * @author gavin
+ */
+public class Person {
+	private Long id;
+	private String name;
+	private String personId;
+	/**
+	 * @return Returns the id.
+	 */
+	public Long getId() {
+		return id;
+	}
+	/**
+	 * @param id The id to set.
+	 */
+	public void setId(Long id) {
+		this.id = id;
+	}
+	/**
+	 * @return Returns the name.
+	 */
+	public String getName() {
+		return name;
+	}
+	/**
+	 * @param name The name to set.
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+	public String getPersonId() {
+		return personId;
+	}
+	
+	public void setPersonId(String personId) {
+		this.personId = personId;
+	}
+	
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/Person.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/SubclassPropertyRefTest.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclasspropertyref/SubclassPropertyRefTest.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,64 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.discrim;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.TestCase;
+
+/**
+ * @author Gavin King
+ */
+public class SubclassPropertyRefTest extends TestCase {
+
+	public SubclassPropertyRefTest(String str) {
+		super( str );
+	}
+
+	protected String[] getMappings() {
+		return new String[] { "propertyref/inheritence/discrim/Person.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new TestSuite( 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();
+	}
+
+}
+


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Account.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/Account.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/Account.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,38 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.joined;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Account implements Serializable {
+	private String accountId;
+	private char type;
+
+	/**
+	 * @return Returns the accountId.
+	 */
+	public String getAccountId() {
+		return accountId;
+	}
+	/**
+	 * @param accountId The accountId to set.
+	 */
+	public void setAccountId(String accountId) {
+		this.accountId = accountId;
+	}
+	/**
+	 * @return Returns the type.
+	 */
+	public char getType() {
+		return type;
+	}
+	/**
+	 * @param type The type to set.
+	 */
+	public void setType(char type) {
+		this.type = type;
+	}
+
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Account.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/BankAccount.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/BankAccount.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/BankAccount.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/BankAccount.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,23 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.joined;
+
+public class BankAccount extends Account {
+	private String accountNumber;
+	private String bsb;
+
+	public String getAccountNumber() {
+		return accountNumber;
+	}
+
+	public void setAccountNumber(String accountNumber) {
+		this.accountNumber = accountNumber;
+	}
+
+	public String getBsb() {
+		return bsb;
+	}
+
+	public void setBsb(String bsb) {
+		this.bsb = bsb;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/BankAccount.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/PropertyRefTest.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/PropertyRefTest.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,70 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.joined;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.TestCase;
+
+/**
+ * @author Gavin King
+ */
+public class JoinedSubclassPropertyRefTest extends TestCase {
+	
+	public JoinedSubclassPropertyRefTest(String str) {
+		super(str);
+	}
+
+	protected String[] getMappings() {
+		return new String[] { "propertyref/inheritence/joined/Person.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new TestSuite( JoinedSubclassPropertyRefTest.class);
+	}
+	
+	public void testPropertyRefToJoinedSubclass() {
+		Session session = openSession();
+		Transaction tx = session.beginTransaction();
+		Person p = new Person();
+		p.setName("Gavin King");
+		BankAccount acc = new BankAccount();
+		acc.setBsb("0634");
+		acc.setType('B');
+		acc.setAccountNumber("xxx-123-abc");
+		p.setBankAccount(acc);
+		session.persist(p);
+		tx.commit();
+		session.close();
+
+		session = openSession();
+		tx = session.beginTransaction();
+		p = (Person) session.get(Person.class, p.getId());
+		assertNotNull( p.getBankAccount() );
+		assertTrue( Hibernate.isInitialized( p.getBankAccount() ) );
+		tx.commit();
+		session.close();
+
+		session = openSession();
+		tx = session.beginTransaction();
+		p = (Person) session.createCriteria(Person.class)
+			.setFetchMode("bankAccount", FetchMode.JOIN)
+			.uniqueResult();
+		assertNotNull( p.getBankAccount() );
+		assertTrue( Hibernate.isInitialized( p.getBankAccount() ) );
+		tx.commit();
+		session.close();
+
+		session = openSession();
+		tx = session.beginTransaction();
+		session.delete(p);
+		tx.commit();
+		session.close();
+	}
+
+}
+


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.hbm.xml (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/Person.hbm.xml)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/Person.hbm.xml	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+  Demonstrates the use of property-ref to map legacy data where
+  foreign keys reference something other than the primary key of
+  the associated entity. Here we show:
+  
+  (1) A one-to-one foreign key association (prefer primary key 
+      associations)
+      
+  (2) A bidirectional one-to-many association on a key that is
+      not the primary key (prefer associations from foreign keys
+      to primary keys)
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.propertyref.inheritence.joined">
+
+	<class name="Person" table="J_SBCLS_PROPREF_PERS">
+		<id name="id">
+			<generator class="hilo"/>
+		</id>
+		<property name="name" length="100"/>
+		<many-to-one name="bankAccount" property-ref="bsbAccountNumber" cascade="all">
+			<column name="bsb"/>
+			<column name="accountNumber"/>
+		</many-to-one>
+	</class>
+	
+	<class name="Account" table="J_SBCLS_PROPREF_ACCT">
+		<id name="accountId" length="32">
+			<generator class="uuid"/>
+		</id>
+		<property name="type" not-null="true"/>
+		<joined-subclass name="BankAccount" table="J_SBCLS_PROPREF_BACCT">
+			<key column="accountId"/>
+			<properties unique="true" name="bsbAccountNumber">
+				<property name="bsb" length="4" not-null="true"/>
+				<property name="accountNumber" length="16" not-null="true"/>
+			</properties>
+		</joined-subclass>
+		
+	</class>
+
+</hibernate-mapping>
\ No newline at end of file


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.hbm.xml
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.java (from rev 10805, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/Person.java)
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joineduid/Person.java	2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,44 @@
+//$Id$
+package org.hibernate.test.propertyref.inheritence.joined;
+
+
+/**
+ * @author gavin
+ */
+public class Person {
+	private Long id;
+	private String name;
+	private BankAccount bankAccount;
+
+	/**
+	 * @return Returns the id.
+	 */
+	public Long getId() {
+		return id;
+	}
+	/**
+	 * @param id The id to set.
+	 */
+	public void setId(Long id) {
+		this.id = id;
+	}
+	/**
+	 * @return Returns the name.
+	 */
+	public String getName() {
+		return name;
+	}
+	/**
+	 * @param name The name to set.
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public BankAccount getBankAccount() {
+		return bankAccount;
+	}
+	public void setBankAccount(BankAccount bankAccount) {
+		this.bankAccount = bankAccount;
+	}
+}


Property changes on: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/Person.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Account.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Account.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Account.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,56 @@
+package org.hibernate.test.propertyref.inheritence.union;
+
+/**
+ * @author Gavin King
+ */
+public class Account {
+	private String accountId;
+	private Customer customer;
+	private Person person;
+	private char type;
+	/**
+	 * @return Returns the user.
+	 */
+	public Customer getCustomer() {
+		return customer;
+	}
+	/**
+	 * @param user The user to set.
+	 */
+	public void setCustomer(Customer user) {
+		this.customer = user;
+	}
+	/**
+	 * @return Returns the accountId.
+	 */
+	public String getAccountId() {
+		return accountId;
+	}
+	/**
+	 * @param accountId The accountId to set.
+	 */
+	public void setAccountId(String accountId) {
+		this.accountId = accountId;
+	}
+	/**
+	 * @return Returns the type.
+	 */
+	public char getType() {
+		return type;
+	}
+	/**
+	 * @param type The type to set.
+	 */
+	public void setType(char type) {
+		this.type = type;
+	}
+	public Person getPerson() {
+		return person;
+	}
+
+	public void setPerson(Person person) {
+		this.person = person;
+	}
+
+
+}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Customer.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Customer.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Customer.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,17 @@
+package org.hibernate.test.propertyref.inheritence.union;
+
+/**
+ * @author Gavin King
+ */
+public class Customer extends Person {
+	private String customerId;
+
+	public String getCustomerId() {
+		return customerId;
+	}
+
+	public void setCustomerId(String customerId) {
+		this.customerId = customerId;
+	}
+
+}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.hbm.xml	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.hbm.xml	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.propertyref.inheritence.union">
+
+	<class name="Person" table="U_SBCLS_PROPREF_PERS">
+		<id name="id">
+			<generator class="hilo"/>
+		</id>
+		<property name="name" length="100"/>
+		<property name="personId" length="8" unique="true"/>
+				
+		<union-subclass name="Customer" table="U_SBCLS_PROPREF_CUST">
+            <property name="customerId" length="8" unique="true"/>
+		</union-subclass>
+	</class>
+	
+	<class name="Account" table="U_SBCLS_PROPREF_ACCT">
+		<id name="accountId" length="32">
+			<generator class="uuid.hex"/>
+		</id>
+		<many-to-one name="person" column="personId" unique="true" property-ref="personId"/>
+		<many-to-one name="customer" column="customerPersonId" unique="true" property-ref="personId"/>
+		<property name="type" not-null="true"/>
+	</class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/Person.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,42 @@
+package org.hibernate.test.propertyref.inheritence.union;
+
+/**
+ * @author gavin
+ */
+public class Person {
+	private Long id;
+	private String name;
+	private String personId;
+	/**
+	 * @return Returns the id.
+	 */
+	public Long getId() {
+		return id;
+	}
+	/**
+	 * @param id The id to set.
+	 */
+	public void setId(Long id) {
+		this.id = id;
+	}
+	/**
+	 * @return Returns the name.
+	 */
+	public String getName() {
+		return name;
+	}
+	/**
+	 * @param name The name to set.
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+	public String getPersonId() {
+		return personId;
+	}
+
+	public void setPersonId(String personId) {
+		this.personId = personId;
+	}
+
+}

Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java	2006-12-05 14:37:32 UTC (rev 10920)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java	2006-12-05 14:39:12 UTC (rev 10921)
@@ -0,0 +1,62 @@
+package org.hibernate.test.propertyref.inheritence.union;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.Hibernate;
+
+/**
+ * @author Gavin King
+ */
+public class UnionSubclassPropertyRefTest extends TestCase {
+
+	public UnionSubclassPropertyRefTest(String str) {
+		super( str );
+	}
+
+	protected String[] getMappings() {
+		return new String[] { "propertyref/inheritence/union/Person.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new TestSuite( 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();
+	}
+
+}




More information about the hibernate-commits mailing list