Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 15:09:18 -0400 (Thu, 29 Mar 2007)
New Revision: 11374
Modified:
trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
Log:
HHH-2534 : better improper HQL collection-dereference error message
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2007-03-29 19:09:07 UTC (rev
11373)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2007-03-29 19:09:18 UTC (rev
11374)
@@ -13,6 +13,7 @@
import junit.framework.Test;
import org.hibernate.Hibernate;
+import org.hibernate.QueryException;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
@@ -34,6 +35,7 @@
import org.hibernate.hql.ast.tree.DotNode;
import org.hibernate.hql.ast.tree.IndexNode;
import org.hibernate.hql.ast.tree.SelectClause;
+import org.hibernate.hql.ast.tree.FromReferenceNode;
/**
* Tests cases where the AST based query translator and the 'classic' query
translator generate identical SQL.
@@ -46,27 +48,41 @@
super( x );
}
- protected boolean dropAfterFailure() {
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( HQLTest.class );
+ }
+
+ public boolean createSchema() {
return false;
}
+ public boolean recreateSchemaAfterFailure() {
+ return false;
+ }
+
protected void prepareTest() throws Exception {
super.prepareTest();
SelectClause.VERSION2_SQL = true;
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = true;
+ DotNode.ILLEGAL_COLL_DEREF_EXCP_BUILDER = new
DotNode.IllegalCollectionDereferenceExceptionBuilder() {
+ public QueryException buildIllegalCollectionDereferenceException(String propertyName,
FromReferenceNode lhs) {
+ throw new QueryException( "illegal syntax near collection: " + propertyName
);
+ }
+ };
}
- public static Test suite() {
- return new FunctionalTestClassTestSuite( HQLTest.class );
- }
-
protected void cleanupTest() throws Exception {
SelectClause.VERSION2_SQL = false;
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = false;
+ DotNode.ILLEGAL_COLL_DEREF_EXCP_BUILDER = DotNode.DEF_ILLEGAL_COLL_DEREF_EXCP_BUILDER;
super.cleanupTest();
}
- //FAILING TESTS:
+ public void testInvalidCollectionDereferencesFail() {
+ // should fail with the same exceptions (because of the
DotNode.ILLEGAL_COLL_DEREF_EXCP_BUILDER injection)
+ assertTranslation( "from Animal a where a.offspring.description =
'xyz'" );
+ assertTranslation( "from Animal a where a.offspring.father.description =
'xyz'" );
+ }
public void testSubComponentReferences() {
assertTranslation( "select c.address.zip.code from ComponentContainer c" );
Show replies by date