Author: steve.ebersole(a)jboss.com
Date: 2006-11-16 16:21:08 -0500 (Thu, 16 Nov 2006)
New Revision: 10832
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/FromElement.java
Log:
minor changes for robustness
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java 2006-11-16
21:20:50 UTC (rev 10831)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java 2006-11-16
21:21:08 UTC (rev 10832)
@@ -600,10 +600,10 @@
}
private boolean checkSubclassOrSuperclassPropertyReference(FromReferenceNode lhs, String
propertyName) {
- if ( lhs != null && !( lhs instanceof IndexNode ) && lhs.getDataType()
!= null && ! lhs.getDataType().isComponentType() ) {
+ if ( lhs != null && !( lhs instanceof IndexNode ) ) {
final FromElement source = lhs.getFromElement();
if ( source != null ) {
- source.handlePropertyBeingDereferenced( propertyName );
+ source.handlePropertyBeingDereferenced( lhs.getDataType(), propertyName );
}
}
return false;
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/FromElement.java
===================================================================
---
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/FromElement.java 2006-11-16
21:20:50 UTC (rev 10831)
+++
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/FromElement.java 2006-11-16
21:21:08 UTC (rev 10832)
@@ -5,6 +5,7 @@
import java.util.List;
import org.hibernate.QueryException;
+import org.hibernate.MappingException;
import org.hibernate.engine.JoinSequence;
import org.hibernate.hql.QueryTranslator;
import org.hibernate.hql.CollectionProperties;
@@ -513,12 +514,19 @@
}
}
- public void handlePropertyBeingDereferenced(String propertyName) {
+ public void handlePropertyBeingDereferenced(Type propertySource, String propertyName) {
if ( getQueryableCollection() != null &&
CollectionProperties.isCollectionProperty( propertyName ) ) {
+ // propertyName refers to something like collection.size...
+ return;
}
- else {
- Queryable persister = getQueryable();
- if ( persister != null ) {
+ if ( propertySource.isComponentType() ) {
+ // property name is a sub-path of a component...
+ return;
+ }
+
+ Queryable persister = getQueryable();
+ if ( persister != null ) {
+ try {
Queryable.Declarer propertyDeclarer = persister.getSubclassPropertyDeclarer(
propertyName );
if ( log.isTraceEnabled() ) {
log.trace( "handling property dereference [" + persister.getEntityName() +
" (" + getClassAlias() + ") -> " + propertyName + " (" +
propertyDeclarer + ")]" );
@@ -531,6 +539,12 @@
dereferencedBySuperclassProperty = true;
}
}
+ catch( QueryException ignore ) {
+ // ignore it; the incoming property could not be found so we
+ // cannot be sure what to do here. At the very least, the
+ // safest is to simply not apply any dereference toggling...
+
+ }
}
}
Show replies by date