Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 15:08:53 -0400 (Thu, 29 Mar 2007)
New Revision: 11372
Modified:
trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
Log:
HHH-2534 : better improper HQL collection-dereference error message
Modified: trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java 2007-03-29 19:08:40 UTC
(rev 11371)
+++ trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java 2007-03-29 19:08:53 UTC
(rev 11372)
@@ -32,9 +32,21 @@
///////////////////////////////////////////////////////////////////////////
// USED ONLY FOR REGRESSION TESTING!!!!
+ //
+ // todo : obviously get rid of all this junk ;)
///////////////////////////////////////////////////////////////////////////
public static boolean useThetaStyleImplicitJoins = false;
public static boolean REGRESSION_STYLE_JOIN_SUPPRESSION = false;
+ public static interface IllegalCollectionDereferenceExceptionBuilder {
+ public QueryException buildIllegalCollectionDereferenceException(String
collectionPropertyName, FromReferenceNode lhs);
+ }
+ public static final IllegalCollectionDereferenceExceptionBuilder
DEF_ILLEGAL_COLL_DEREF_EXCP_BUILDER = new IllegalCollectionDereferenceExceptionBuilder()
{
+ public QueryException buildIllegalCollectionDereferenceException(String propertyName,
FromReferenceNode lhs) {
+ String lhsPath = ASTUtil.getPathText( lhs );
+ return new QueryException( "illegal attempt to dereference collection [" +
lhsPath + "] with element property reference [" + propertyName + "]"
);
+ }
+ };
+ public static IllegalCollectionDereferenceExceptionBuilder
ILLEGAL_COLL_DEREF_EXCP_BUILDER = DEF_ILLEGAL_COLL_DEREF_EXCP_BUILDER;
///////////////////////////////////////////////////////////////////////////
private static final Log log = LogFactory.getLog( DotNode.class );
@@ -186,24 +198,26 @@
return;
}
- // The property is a component...
if ( propertyType.isComponentType() ) {
+ // The property is a component...
checkLhsIsNotCollection();
dereferenceComponent( parent );
initText();
}
- // The property is another class..
else if ( propertyType.isEntityType() ) {
+ // The property is another class..
checkLhsIsNotCollection();
dereferenceEntity( ( EntityType ) propertyType, implicitJoin, classAlias,
generateJoin, parent );
initText();
}
- // The property is a collection...
else if ( propertyType.isCollectionType() ) {
+ // The property is a collection...
checkLhsIsNotCollection();
dereferenceCollection( ( CollectionType ) propertyType, implicitJoin, false,
classAlias, parent );
}
- else { // Otherwise, this is a primitive type.
+ else {
+ // Otherwise, this is a primitive type.
+ checkLhsIsNotCollection();
dereferenceType = DEREF_PRIMITIVE;
initText();
}
@@ -493,9 +507,7 @@
private void checkLhsIsNotCollection() throws SemanticException {
if ( getLhs().getDataType() != null &&
getLhs().getDataType().isCollectionType() ) {
- // TODO : this exactly matches the output of the old parser, but we might want to be
more explicit here
- // that will however cause regression issues in HQLTest
- throw new SemanticException( "illegal syntax near collection: " +
propertyName );
+ throw ILLEGAL_COLL_DEREF_EXCP_BUILDER.buildIllegalCollectionDereferenceException(
propertyName, getLhs() );
}
}
private void dereferenceComponent(AST parent) {
Show replies by date