|
From: <hib...@li...> - 2006-07-10 17:13:00
|
Author: ste...@jb...
Date: 2006-07-10 13:12:36 -0400 (Mon, 10 Jul 2006)
New Revision: 10101
Modified:
trunk/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java
Log:
HHH-1710 : collections based on property-ref to secondary table could not be joined in HQL
Modified: trunk/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java 2006-07-10 16:31:09 UTC (rev 10100)
+++ trunk/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java 2006-07-10 17:12:36 UTC (rev 10101)
@@ -1321,10 +1321,18 @@
* which takes the entity name.
*/
public int getSubclassPropertyTableNumber(String propertyPath) {
- final String rootPropertyName = StringHelper.root(propertyPath);
+ String rootPropertyName = StringHelper.root(propertyPath);
Type type = propertyMapping.toType(rootPropertyName);
- if ( type.isAssociationType() && ( (AssociationType) type ).useLHSPrimaryKey() ) {
- return 0;
+ if ( type.isAssociationType() ) {
+ AssociationType assocType = ( AssociationType ) type;
+ if ( assocType.useLHSPrimaryKey() ) {
+ // performance op to avoid the array search
+ return 0;
+ }
+ else if ( type.isCollectionType() ) {
+ // properly handle property-ref-based associations
+ rootPropertyName = assocType.getLHSPropertyName();
+ }
}
//Enable for HHH-440, which we don't like:
/*if ( type.isComponentType() && !propertyName.equals(rootPropertyName) ) {
|