Author: steve.ebersole(a)jboss.com
Date: 2006-12-07 09:50:59 -0500 (Thu, 07 Dec 2006)
New Revision: 10946
Added:
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/InvalidWithClauseException.java
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/HqlSqlWalker.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/WithClauseTest.java
Log:
specialized InvalidWithClauseException
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/HqlSqlWalker.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/HqlSqlWalker.java 2006-12-07
14:50:42 UTC (rev 10945)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/HqlSqlWalker.java 2006-12-07
14:50:59 UTC (rev 10946)
@@ -15,7 +15,6 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.QueryException;
import org.hibernate.HibernateException;
-import org.hibernate.impl.FilterImpl;
import org.hibernate.engine.JoinSequence;
import org.hibernate.engine.ParameterBinder;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -62,7 +61,6 @@
import org.hibernate.param.PositionalParameterSpecification;
import org.hibernate.param.VersionTypeSeedParameterSpecification;
import org.hibernate.param.CollectionFilterKeyParameterSpecification;
-import org.hibernate.param.DynamicFilterParameterSpecification;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.sql.JoinFragment;
@@ -336,7 +334,7 @@
traverser.traverseDepthFirst( hqlSqlWithNode );
FromElement referencedFromElement = visitor.getReferencedFromElement();
if ( referencedFromElement != fromElement ) {
- throw new SemanticException( "with-clause expressions did not reference
from-clause element to which the with-clause was associated" );
+ throw new InvalidWithClauseException( "with-clause expressions did not reference
from-clause element to which the with-clause was associated" );
}
SqlGenerator sql = new SqlGenerator( getSessionFactoryHelper().getFactory() );
sql.whereExpr( hqlSqlWithNode.getFirstChild() );
@@ -346,6 +344,9 @@
catch( SemanticException e ) {
throw e;
}
+ catch( InvalidWithClauseException e ) {
+ throw e;
+ }
catch ( Exception e) {
throw new SemanticException( e.getMessage() );
}
@@ -383,7 +384,7 @@
// creates and renders the join fragments for inheritence
// hierarchies...
if ( !joinAlias.equals( referencedFromElement.getTableAlias() ) ) {
- throw new HibernateException( "with clause can only reference columns in the
driving table" );
+ throw new InvalidWithClauseException( "with clause can only reference columns
in the driving table" );
}
}
}
Added:
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/InvalidWithClauseException.java
===================================================================
---
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/InvalidWithClauseException.java 2006-12-07
14:50:42 UTC (rev 10945)
+++
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/InvalidWithClauseException.java 2006-12-07
14:50:59 UTC (rev 10946)
@@ -0,0 +1,18 @@
+package org.hibernate.hql.ast;
+
+import org.hibernate.QueryException;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class InvalidWithClauseException extends QuerySyntaxException {
+ public InvalidWithClauseException(String message) {
+ super( message );
+ }
+
+ public InvalidWithClauseException(String message, String queryString) {
+ super( message, queryString );
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/WithClauseTest.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/WithClauseTest.java 2006-12-07
14:50:42 UTC (rev 10945)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/WithClauseTest.java 2006-12-07
14:50:59 UTC (rev 10946)
@@ -6,6 +6,7 @@
import org.hibernate.Transaction;
import org.hibernate.HibernateException;
import org.hibernate.QueryException;
+import org.hibernate.hql.ast.InvalidWithClauseException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -76,10 +77,7 @@
.list();
fail( "failure expected" );
}
- catch( QueryException qe ) {
- if ( qe.getMessage().indexOf( "can only reference columns in the driving
table" ) < 0 ) {
- fail( "unexpected failure type [" + qe.getMessage() + "]" );
- }
+ catch( InvalidWithClauseException expected ) {
}
try {
@@ -87,10 +85,7 @@
.list();
fail( "failure expected" );
}
- catch( QueryException qe ) {
- if ( qe.getMessage().indexOf( "with-clause expressions did not reference
from-clause element to which the with-clause was associated" ) < 0 ) {
- fail( "unexpected failure type [" + qe.getMessage() + "]" );
- }
+ catch( InvalidWithClauseException expected ) {
}
try {
@@ -99,10 +94,7 @@
.list();
fail( "failure expected" );
}
- catch( QueryException qe ) {
- if ( qe.getMessage().indexOf( "with-clause expressions did not reference
from-clause element to which the with-clause was associated" ) < 0 ) {
- fail( "unexpected failure type [" + qe.getMessage() + "]" );
- }
+ catch( InvalidWithClauseException expected ) {
}
txn.commit();
Show replies by date