|
From: <hib...@li...> - 2006-06-30 05:59:49
|
Author: ste...@jb...
Date: 2006-06-30 01:59:31 -0400 (Fri, 30 Jun 2006)
New Revision: 10071
Added:
branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/redesign/
branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/redesign/ParserTest.java
branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/redesign/ResolverTest.java
Removed:
branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/HqlResolverTest.java
Log:
redid parse phase and simplified portions of resolve phase
Deleted: branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/HqlResolverTest.java
===================================================================
--- branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/HqlResolverTest.java 2006-06-30 05:55:55 UTC (rev 10070)
+++ branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/HqlResolverTest.java 2006-06-30 05:59:31 UTC (rev 10071)
@@ -1,191 +0,0 @@
-package org.hibernate.test.hql;
-
-import antlr.RecognitionException;
-import antlr.TokenStreamException;
-import antlr.collections.AST;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.hql.antlr.HqlRTokenTypes;
-import org.hibernate.hql.ast.resolve.HqlResolver;
-import org.hibernate.hql.ast.resolve.StatementNode;
-import org.hibernate.hql.ast.resolve.SelectStatementNode;
-import org.hibernate.hql.ast.util.ASTPrinter;
-import org.hibernate.hql.ast.util.NodeTraverser;
-import org.hibernate.test.TestCase;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * Tests the new HQL resolver phase.
- * <br>User: Joshua Davis
- * Date: Apr 1, 2006
- * Time: 7:25:37 AM
- */
-public class HqlResolverTest extends TestCase {
- private static final ASTPrinter hqlrPrinter = generatePrinter();
-
- private static ASTPrinter generatePrinter() {
- ASTPrinter rtn = new ASTPrinter( HqlRTokenTypes.class );
- rtn.setShowClassNames( false );
- return rtn;
- }
-
- public HqlResolverTest(String n) {
- super( n );
- }
-
- public void testSimpleHql() throws Exception {
- // First, get an AST by parsing some HQL text.
- AST ast = resolve( "from Animal" );
- // Assert:
- // The root node should be a statement.
- assertTrue( ast instanceof SelectStatementNode );
- }
-
- public void testSelectExpression() throws Throwable {
- resolve( "select a from Animal a" );
- resolve( "select a.mother as m from Animal as a" );
- }
-
- public void testExplicitImplicitJoin() throws Exception {
- AST ast = resolve( "from Animal a left join fetch a.mother.mother.mother as ggm where ggm.name like '%weeble%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 3, ast );
- }
-
- public void testExplicitCollectionJoin() throws Throwable {
- AST ast = resolve( "from Animal as a inner join a.offspring as o where o.name like '%boots%'" );
- }
-
- public void testSimpleImplicitJoin() throws Exception {
- AST ast = resolve( "from Animal a where a.mother.name like '%mary%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 1, ast );
-
- ast = resolve( "from Animal a where a.mother.mother.name like '%weeble%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 2, ast );
-
- ast = resolve( "from Animal a where a.mother.mother = ?" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 1, ast );
- }
-
- public void testUnqualifiedPropertyReference() throws Exception {
- AST ast = resolve( "from Animal where name like '%mary%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 0, ast );
-
- ast = resolve( "from Animal where mother.name like '%mary%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 1, ast );
- }
-
- public void testThetaJoins() throws Exception {
- AST ast = resolve( "from Animal a, Animal b where a.mother.id = b.id and b.name like '%mary%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 1, ast );
-
- ast = resolve( "from Animal a, Animal b inner join b.mother as c where a.mother.id = b.id and b.name like '%mary%'" );
- assertTrue( ast instanceof SelectStatementNode );
- JoinCounter.assertJoinCount( 2, ast );
- }
-
- public void testIndexOperation() throws Throwable {
- AST ast = null;
-
- // todo : these are all goofed up...
- ast = resolve( "from Zoo zoo where zoo.mammals['dog'].father.description like '%black%'" );
- assertTrue( ast instanceof StatementNode );
-
- ast = resolve( "from Zoo zoo join zoo.animals an where zoo.mammals[ index(an) ] = an" );
- assertTrue( ast instanceof StatementNode );
- }
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- private AST resolve(String hql) throws RecognitionException, TokenStreamException {
- AST hqlAst = HqlParserTest.doParse(hql,false);
- // Now, pass it though the resolver phase, which yeilds
- // a processed HQL AST.
- HqlResolver resolver = new HqlResolver( getSessionFactoryImplementor() );
- resolver.statement( hqlAst );
- AST resolvedHql = resolver.getAST();
- System.out.println(
- hqlrPrinter.showAsString( resolvedHql, "Resolved AST : " + resolvedHql.toStringTree() + "" )
- );
- return resolvedHql;
- }
-
- protected SessionFactoryImplementor getSessionFactoryImplementor() {
- SessionFactoryImplementor factory = ( SessionFactoryImplementor ) getSessions();
- if ( factory == null ) {
- throw new NullPointerException( "Unable to create factory!" );
- }
- return factory;
- }
-
- private static class JoinCounter implements NodeTraverser.VisitationStrategy {
- int count = 0;
- public void visit(AST node) {
- if ( node.getType() == HqlRTokenTypes.JOIN ) {
- count++;
- }
- }
- public static void assertJoinCount(int expected, AST tree) {
- assertJoinCount( "incorrect join count", expected, tree );
- }
- public static void assertJoinCount(String failMessage, int expected, AST tree) {
- JoinCounter counter = new JoinCounter();
- NodeTraverser walker = new NodeTraverser( counter );
- walker.traverseDepthFirst( tree );
- assertEquals( failMessage, expected, counter.count );
- }
- }
-
- public static Test suite() {
- return new TestSuite(HqlResolverTest.class);
- }
-
- protected String[] getMappings() {
- return new String[]{
- "hql/Animal.hbm.xml",
- "hql/EntityWithCrazyCompositeKey.hbm.xml",
- "batchfetch/ProductLine.hbm.xml",
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Commento.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Custom.hbm.xml",
- "legacy/Eye.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Marelo.hbm.xml",
- "legacy/MasterDetail.hbm.xml",
- "legacy/Middle.hbm.xml",
- "legacy/Multi.hbm.xml",
- "legacy/Nameable.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/WZ.hbm.xml",
- "legacy/UpDown.hbm.xml",
- "compositeelement/Parent.hbm.xml",
- "onetoone/joined/Person.hbm.xml",
- "hql/CrazyIdFieldNames.hbm.xml"
- };
- }
-
- protected boolean recreateSchema() {
- // we do not need to create the schema for these parser tests
- return false;
- }
-}
Added: branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/redesign/ParserTest.java
===================================================================
--- branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/redesign/ParserTest.java 2006-06-30 05:55:55 UTC (rev 10070)
+++ branches/HQL_ANTLR_2/Hibernate3/test/org/hibernate/test/hql/redesign/ParserTest.java 2006-06-30 05:59:31 UTC (rev 10071)
@@ -0,0 +1,1153 @@
+package org.hibernate.test.hql.redesign;
+
+import junit.framework.TestCase;
+import org.hibernate.hql.antlr.ParseTokenTypes;
+import org.hibernate.hql.ast.util.ASTPrinter;
+import org.hibernate.hql.ast.util.ASTIterator;
+import org.hibernate.hql.ast.parse.HqlParser;
+import org.hibernate.hql.ast.tree.Node;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import antlr.collections.AST;
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+
+/**
+ * todo: describe ParserTest
+ *
+ * @author Steve Ebersole
+ */
+public class ParserTest extends TestCase implements ParseTokenTypes {
+
+ public static final Log log = LogFactory.getLog( ParserTest.class );
+
+ public static final String CONSTANT = "constant-value";
+
+ public void testEntityReferenceRule() throws Throwable {
+ String entityName = "com.acme.XYZ";
+ HqlParser parser = buildHqlParser( entityName );
+ parser.fromClassOrOuterQueryPath();
+ AST result = parser.getAST().getFirstChild();
+ show( result, "entity-name-result" );
+ assertEquals( ENTITY_NAME, result.getType() );
+ assertEquals( entityName, result.getText() );
+
+ entityName = "XYZ";
+ parser = buildHqlParser( entityName );
+ parser.fromClassOrOuterQueryPath();
+ result = parser.getAST().getFirstChild();
+ show( result, "entity-name-result" );
+ assertEquals( ENTITY_NAME, result.getType() );
+ assertEquals( entityName, result.getText() );
+ }
+
+ public void testSimpleFrom() throws Throwable {
+ String entityName = "com.acme.XYZ";
+ HqlParser parser = buildHqlParser( "from " + entityName + " as e" );
+ parser.statement();
+ AST result = parser.getAST();
+ show( result, "simple-from-result" );
+ }
+
+ public void testConstantUsage() throws Throwable {
+ HqlParser parser = buildHqlParser( "from com.acme.XYZ where prop = org.hibernate.test.hql.redesign.ParserTest.CONSTANT" );
+ parser.statement();
+ AST result = parser.getAST();
+ show( result, "constant" );
+ AST constantNode = result.getFirstChild().getNextSibling().getFirstChild().getFirstChild().getNextSibling();
+ assertEquals( JAVA_CONSTANT, constantNode.getType() );
+
+ // apply control checks
+ parser = buildHqlParser( "from com.acme.XYZ where prop = compProp.subProp" );
+ parser.statement();
+ result = parser.getAST();
+ show( result, "constant-control" );
+ AST checkNode = result.getFirstChild().getNextSibling().getFirstChild().getFirstChild().getNextSibling();
+ assertEquals( DOT, checkNode.getType() );
+
+ }
+
+ public void testEntityNamePathWithKeyword() throws Exception {
+ parse( "from org.hibernate.test.Inner" );
+ }
+
+ public void testWhereClauseIdentPrimaryWithEmbeddedKeyword() throws Exception {
+ parse( "from org.hibernate.test.Inner i where i.outer.inner.middle = 'xyz'" );
+ }
+
+ public void testDynamicInstantiation() throws Exception {
+ parse( "select new list(a, mate) from Animal a join a.mate as mate" );
+ parse( "select new Family(mother, mate, offspr) from eg.DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr" );
+ }
+
+ public void testListOrMapKeywordReference() throws Exception {
+ parse( "select p from eg.NameList nl, eg.Person p where p.name = some elements(nl.names)" );
+ parse( "select p from eg.NameList list, eg.Person p where p.name = some elements(list.names)" );
+ parse( "select p from eg.NameList map, eg.Person p where p.name = some elements(map.names)" );
+ }
+
+ public void testExplicitPropertyJoin() throws Exception {
+ parse( "from eg.Cat as cat inner join fetch cat.mate as m fetch all properties left join fetch cat.kittens as k" );
+ }
+
+ private void show(AST node, String header) {
+ ASTPrinter printer = new ASTPrinter( ParseTokenTypes.class );
+ printer.setShowClassNames( false );
+ log.info( printer.showAsString( node, header ) );
+ }
+
+ // tests copied over from org.hibernate.test.hql.HqlParserTest ~~~~~~~~~~~~
+
+ public void testUnion() throws Exception {
+ parse("from Animal a where a in (from Cat union from Dog) ");
+ }
+
+ /**
+ * Section 9.2 - from *
+ */
+ public void testDocoExamples92() throws Exception {
+ parse( "from eg.Cat" );
+ parse( "from eg.Cat as cat" );
+ parse( "from eg.Cat cat" );
+ parse( "from Formula, Parameter" );
+ parse( "from Formula as form, Parameter as param" );
+ }
+
+ /**
+ * Section 9.3 - Associations and joins *
+ */
+ public void testDocoExamples93() throws Exception {
+ parse( "from eg.Cat as cat inner join cat.mate as mate left outer join cat.kittens as kitten" );
+ parse( "from eg.Cat as cat left join cat.mate.kittens as kittens" );
+ parse( "from Formula form full join form.parameter param" );
+ parse( "from eg.Cat as cat join cat.mate as mate left join cat.kittens as kitten" );
+ parse( "from eg.Cat as cat\ninner join fetch cat.mate\nleft join fetch cat.kittens" );
+ }
+
+ /**
+ * Section 9.4 - Select *
+ */
+ public void testDocoExamples94() throws Exception {
+ parse( "select mate from eg.Cat as cat inner join cat.mate as mate" );
+ parse( "select cat.mate from eg.Cat cat" );
+ parse( "select elements(cat.kittens) from eg.Cat cat" );
+ parse( "select cat.name from eg.DomesticCat cat where cat.name like 'fri%'" );
+ parse( "select cust.name.firstName from Customer as cust" );
+ parse( "select mother, offspr, mate.name from eg.DomesticCat\n"
+ + " as mother inner join mother.mate as mate left outer join\n"
+ + "mother.kittens as offspr" );
+ parse( "select new Family(mother, mate, offspr)\n"
+ + "from eg.DomesticCat as mother\n"
+ + "join mother.mate as mate\n"
+ + "left join mother.kittens as offspr\n" );
+ }
+
+ /**
+ * Section 9.5 - Aggregate functions *
+ */
+ public void testDocoExamples95() throws Exception {
+ parse( "select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)\n"
+ + "from eg.Cat cat" );
+ parse( "select cat, count( elements(cat.kittens) )\n"
+ + " from eg.Cat cat group by cat" );
+ parse( "select distinct cat.name from eg.Cat cat" );
+ parse( "select count(distinct cat.name), count(cat) from eg.Cat cat" );
+ }
+
+ /**
+ * Section 9.6 - Polymorphism *
+ */
+ public void testDocoExamples96() throws Exception {
+ parse( "from eg.Cat as cat" );
+ parse( "from java.lang.Object o" );
+ parse( "from eg.Named n, eg.Named m where n.name = m.name" );
+ }
+
+ /**
+ * Section 9.7 - Where *
+ */
+ public void testDocoExamples97() throws Exception {
+ parse( "from eg.Cat as cat where cat.name='Fritz'" );
+ parse( "select foo\n"
+ + "from eg.Foo foo, eg.Bar bar\n"
+ + "where foo.startDate = bar.date\n" );
+ parse( "from eg.Cat cat where cat.mate.name is not null" );
+ parse( "from eg.Cat cat, eg.Cat rival where cat.mate = rival.mate" );
+ parse( "select cat, mate\n"
+ + "from eg.Cat cat, eg.Cat mate\n"
+ + "where cat.mate = mate" );
+ parse( "from eg.Cat as cat where cat.id = 123" );
+ parse( "from eg.Cat as cat where cat.mate.id = 69" );
+ parse( "from bank.Person person\n"
+ + "where person.id.country = 'AU'\n"
+ + "and person.id.medicareNumber = 123456" );
+ parse( "from bank.Account account\n"
+ + "where account.owner.id.country = 'AU'\n"
+ + "and account.owner.id.medicareNumber = 123456" );
+ parse( "from eg.Cat cat where cat.class = eg.DomesticCat" );
+ parse( "from eg.AuditLog log, eg.Payment payment\n"
+ + "where log.item.class = 'eg.Payment' and log.item.id = payment.id" );
+ }
+
+ /**
+ * Section 9.8 - Expressions *
+ */
+ public void testDocoExamples98() throws Exception {
+ parse( "from eg.DomesticCat cat where cat.name between 'A' and 'B'" );
+ parse( "from eg.DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' )" );
+ parse( "from eg.DomesticCat cat where cat.name not between 'A' and 'B'" );
+ parse( "from eg.DomesticCat cat where cat.name not in ( 'Foo', 'Bar', 'Baz' )" );
+ parse( "from eg.Cat cat where cat.kittens.size > 0" );
+ parse( "from eg.Cat cat where size(cat.kittens) > 0" );
+// This is a little odd. I'm not sure whether 'current' is a keyword.
+// parse("from Calendar cal where cal.holidays.maxElement > current date");
+// Using the token 'order' as both a keyword and an identifier works now, but
+// the second instance causes some problems because order is valid in the second instance.
+// parse("from Order order where maxindex(order.items) > 100");
+// parse("from Order order where minelement(order.items) > 10000");
+ parse( "from Order ord where maxindex(ord.items) > 100" );
+ parse( "from Order ord where minelement(ord.items) > 10000" );
+
+ parse( "select mother from eg.Cat as mother, eg.Cat as kit\n"
+ + "where kit in elements(foo.kittens)" );
+ parse( "select p from eg.NameList list, eg.Person p\n"
+ + "where p.name = some elements(list.names)" );
+ parse( "from eg.Cat cat where exists elements(cat.kittens)" );
+ parse( "from eg.Player p where 3 > all elements(p.scores)" );
+ parse( "from eg.Show show where 'fizard' in indices(show.acts)" );
+
+ // Yet another example of the pathological 'order' token.
+// parse("from Order order where order.items[0].id = 1234");
+// parse("select person from Person person, Calendar calendar\n"
+// + "where calendar.holidays['national day'] = person.birthDay\n"
+// + "and person.nationality.calendar = calendar");
+// parse("select item from Item item, Order order\n"
+// + "where order.items[ order.deliveredItemIndices[0] ] = item and order.id = 11");
+// parse("select item from Item item, Order order\n"
+// + "where order.items[ maxindex(order.items) ] = item and order.id = 11");
+
+ parse( "from Order ord where ord.items[0].id = 1234" );
+ parse( "select person from Person person, Calendar calendar\n"
+ + "where calendar.holidays['national day'] = person.birthDay\n"
+ + "and person.nationality.calendar = calendar" );
+ parse( "select item from Item item, Order ord\n"
+ + "where ord.items[ ord.deliveredItemIndices[0] ] = item and ord.id = 11" );
+ parse( "select item from Item item, Order ord\n"
+ + "where ord.items[ maxindex(ord.items) ] = item and ord.id = 11" );
+
+ parse( "select item from Item item, Order ord\n"
+ + "where ord.items[ size(ord.items) - 1 ] = item" );
+
+ parse( "from eg.DomesticCat cat where upper(cat.name) like 'FRI%'" );
+
+ parse( "select cust from Product prod, Store store\n"
+ + "inner join store.customers cust\n"
+ + "where prod.name = 'widget'\n"
+ + "and store.location.name in ( 'Melbourne', 'Sydney' )\n"
+ + "and prod = all elements(cust.currentOrder.lineItems)" );
+
+ }
+
+ public void testDocoExamples99() throws Exception {
+ parse( "from eg.DomesticCat cat\n"
+ + "order by cat.name asc, cat.weight desc, cat.birthdate" );
+ }
+
+ public void testDocoExamples910() throws Exception {
+ parse( "select cat.color, sum(cat.weight), count(cat)\n"
+ + "from eg.Cat cat group by cat.color" );
+ parse( "select foo.id, avg( elements(foo.names) ), max( indices(foo.names) )\n"
+ + "from eg.Foo foo group by foo.id" );
+ parse( "select cat.color, sum(cat.weight), count(cat)\n"
+ + "from eg.Cat cat group by cat.color\n"
+ + "having cat.color in (eg.Color.TABBY, eg.Color.BLACK)" );
+ parse( "select cat from eg.Cat cat join cat.kittens kitten\n"
+ + "group by cat having avg(kitten.weight) > 100\n"
+ + "order by count(kitten) asc, sum(kitten.weight) desc" );
+ }
+
+ public void testDocoExamples911() throws Exception {
+ parse( "from eg.Cat as fatcat where fatcat.weight > (\n"
+ + "select avg(cat.weight) from eg.DomesticCat cat)" );
+ parse( "from eg.DomesticCat as cat where cat.name = some (\n"
+ + "select name.nickName from eg.Name as name)\n" );
+ parse( "from eg.Cat as cat where not exists (\n"
+ + "from eg.Cat as mate where mate.mate = cat)" );
+ parse( "from eg.DomesticCat as cat where cat.name not in (\n"
+ + "select name.nickName from eg.Name as name)" );
+ }
+
+ public void testDocoExamples912() throws Exception {
+ parse( "select ord.id, sum(price.amount), count(item)\n"
+ + "from Order as ord join ord.lineItems as item\n"
+ + "join item.product as product, Catalog as catalog\n"
+ + "join catalog.prices as price\n"
+ + "where ord.paid = false\n"
+ + "and ord.customer = :customer\n"
+ + "and price.product = product\n"
+ + "and catalog.effectiveDate < sysdate\n"
+ + "and catalog.effectiveDate >= all (\n"
+ + "select cat.effectiveDate from Catalog as cat where cat.effectiveDate < sysdate)\n"
+ + "group by ord\n"
+ + "having sum(price.amount) > :minAmount\n"
+ + "order by sum(price.amount) desc" );
+
+ parse( "select ord.id, sum(price.amount), count(item)\n"
+ + "from Order as ord join ord.lineItems as item join item.product as product,\n"
+ + "Catalog as catalog join catalog.prices as price\n"
+ + "where ord.paid = false and ord.customer = :customer\n"
+ + "and price.product = product and catalog = :currentCatalog\n"
+ + "group by ord having sum(price.amount) > :minAmount\n"
+ + "order by sum(price.amount) desc" );
+
+ parse( "select count(payment), status.name \n"
+ + "from Payment as payment \n"
+ + " join payment.currentStatus as status\n"
+ + " join payment.statusChanges as statusChange\n"
+ + "where payment.status.name <> PaymentStatus.AWAITING_APPROVAL\n"
+ + " or (\n"
+ + " statusChange.timeStamp = ( \n"
+ + " select max(change.timeStamp) \n"
+ + " from PaymentStatusChange change \n"
+ + " where change.payment = payment\n"
+ + " )\n"
+ + " and statusChange.user <> :currentUser\n"
+ + " )\n"
+ + "group by status.name, status.sortOrder\n"
+ + "order by status.sortOrder" );
+ parse( "select count(payment), status.name \n"
+ + "from Payment as payment\n"
+ + " join payment.currentStatus as status\n"
+ + "where payment.status.name <> PaymentStatus.AWAITING_APPROVAL\n"
+ + " or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :currentUser\n"
+ + "group by status.name, status.sortOrder\n"
+ + "order by status.sortOrder" );
+ parse( "select account, payment\n"
+ + "from Account as account\n"
+ + " left outer join account.payments as payment\n"
+ + "where :currentUser in elements(account.holder.users)\n"
+ + " and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID)\n"
+ + "order by account.type.sortOrder, account.accountNumber, payment.dueDate" );
+ parse( "select account, payment\n"
+ + "from Account as account\n"
+ + " join account.holder.users as user\n"
+ + " left outer join account.payments as payment\n"
+ + "where :currentUser = user\n"
+ + " and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID)\n"
+ + "order by account.type.sortOrder, account.accountNumber, payment.dueDate" );
+ }
+
+ public void testExamples1() throws Exception {
+ parse( "select new org.hibernate.test.S(s.count, s.address)\n"
+ + "from s in class Simple" );
+ parse( "select s.name, sysdate, trunc(s.pay), round(s.pay) from s in class Simple" );
+ parse( "select round(s.pay, 2) from s" );
+ parse( "select abs(round(s.pay)) from s in class Simple" );
+ parse( "select trunc(round(sysdate)) from s in class Simple" );
+ }
+
+ public void testArrayExpr() throws Exception {
+ parse( "from Order ord where ord.items[0].id = 1234" );
+ }
+
+ public void testMultipleActualParameters() throws Exception {
+ parse( "select round(s.pay, 2) from s" );
+ }
+
+ public void testMultipleFromClasses() throws Exception {
+ parse( "FROM eg.mypackage.Cat qat, com.toadstool.Foo f" );
+ parse( "FROM eg.mypackage.Cat qat, org.jabberwocky.Dipstick" );
+ }
+
+ public void testFromWithJoin() throws Exception {
+ parse( "FROM eg.mypackage.Cat qat, com.toadstool.Foo f join net.sf.blurb.Blurb" );
+ parse( "FROM eg.mypackage.Cat qat left join com.multijoin.JoinORama , com.toadstool.Foo f join net.sf.blurb.Blurb" );
+ }
+
+ public void testSelect() throws Exception {
+ parse( "SELECT f FROM eg.mypackage.Cat qat, com.toadstool.Foo f join net.sf.blurb.Blurb" );
+ parse( "SELECT DISTINCT bar FROM eg.mypackage.Cat qat left join com.multijoin.JoinORama as bar, com.toadstool.Foo f join net.sf.blurb.Blurb" );
+ parse( "SELECT count(*) FROM eg.mypackage.Cat qat" );
+ parse( "SELECT avg(qat.weight) FROM eg.mypackage.Cat qat" );
+ }
+
+ public void testWhere() throws Exception {
+ parse( "FROM eg.mypackage.Cat qat where qat.name like '%fluffy%' or qat.toes > 5" );
+ parse( "FROM eg.mypackage.Cat qat where not qat.name like '%fluffy%' or qat.toes > 5" );
+ parse( "FROM eg.mypackage.Cat qat where not qat.name not like '%fluffy%'" );
+ parse( "FROM eg.mypackage.Cat qat where qat.name in ('crater','bean','fluffy')" );
+ parse( "FROM eg.mypackage.Cat qat where qat.name not in ('crater','bean','fluffy')" );
+ parse( "from Animal an where sqrt(an.bodyWeight)/2 > 10" );
+ parse( "from Animal an where (an.bodyWeight > 10 and an.bodyWeight < 100) or an.bodyWeight is null" );
+ }
+
+ public void testGroupBy() throws Exception {
+ parse( "FROM eg.mypackage.Cat qat group by qat.breed" );
+ parse( "FROM eg.mypackage.Cat qat group by qat.breed, qat.eyecolor" );
+ }
+
+ public void testOrderBy() throws Exception {
+ parse( "FROM eg.mypackage.Cat qat order by avg(qat.toes)" );
+ parse( "from Animal an order by sqrt(an.bodyWeight)/2" );
+ }
+
+ public void testDoubleLiteral() throws Exception {
+ parse( "from eg.Cat as tinycat where fatcat.weight < 3.1415" );
+ parse( "from eg.Cat as enormouscat where fatcat.weight > 3.1415e3" );
+ }
+
+ public void testComplexConstructor() throws Exception {
+ parse( "select new Foo(count(bar)) from bar" );
+ parse( "select new Foo(count(bar),(select count(*) from doofus d where d.gob = 'fat' )) from bar" );
+ }
+
+
+ public void testInNotIn() throws Exception {
+ parse( "from foo where foo.bar in ('a' , 'b', 'c')" );
+ parse( "from foo where foo.bar not in ('a' , 'b', 'c')" );
+ }
+
+ public void testOperatorPrecedence() throws Exception {
+ parse( "from foo where foo.bar = 123 + foo.baz * foo.not" );
+ parse( "from foo where foo.bar like 'testzzz' || foo.baz or foo.bar in ('duh', 'gob')" );
+ }
+
+ /**
+ * Tests HQL generated by the other unit tests.
+ *
+ * @throws Exception if the HQL could not be parsed.
+ */
+ public void testUnitTestHql() throws Exception {
+ parse( "select foo from foo in class org.hibernate.test.Foo, fee in class org.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id" );
+ parse( "select foo.foo, foo.dependent from foo in class org.hibernate.test.Foo order by foo.foo.string desc, foo.component.count asc, foo.dependent.id" );
+ parse( "select foo from foo in class org.hibernate.test.Foo order by foo.dependent.id, foo.dependent.fi" );
+ parse( "SELECT one FROM one IN CLASS org.hibernate.test.One ORDER BY one.value ASC" );
+ parse( "SELECT many.one FROM many IN CLASS org.hibernate.test.Many ORDER BY many.one.value ASC, many.one.id" );
+ parse( "select foo.id from org.hibernate.test.Foo foo where foo.joinedProp = 'foo'" );
+ parse( "from org.hibernate.test.Foo foo inner join fetch foo.foo" );
+ parse( "from org.hibernate.test.Baz baz left outer join fetch baz.fooToGlarch" );
+ parse( "select foo.foo.foo.string from foo in class org.hibernate.test.Foo where foo.foo = 'bar'" );
+ parse( "select foo.foo.foo.foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo = 'bar'" );
+ parse( "select foo.foo.foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo.foo.string = 'bar'" );
+ parse( "select foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'" );
+ parse( "select foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo.foo.string = 'a' and foo.foo.string = 'b'" );
+ parse( "from org.hibernate.test.Foo as foo where foo.component.glarch.name is not null" );
+ parse( "from org.hibernate.test.Foo as foo left outer join foo.component.glarch as glarch where glarch.name = 'foo'" );
+ parse( "from org.hibernate.test.Foo" );
+ parse( "from org.hibernate.test.Foo foo left outer join foo.foo" );
+ parse( "from org.hibernate.test.Foo, org.hibernate.test.Bar" );
+ parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch, org.hibernate.test.Bar bar join bar.foo" );
+ parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch join baz.fooSet" );
+ parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch join fetch baz.fooSet foo left join fetch foo.foo" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.string='osama bin laden' and foo.boolean = true order by foo.string asc, foo.component.count desc" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.string='osama bin laden' order by foo.string asc, foo.component.count desc" );
+ parse( "select foo.foo from foo in class org.hibernate.test.Foo" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.component.count is null order by foo.component.count" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.component.name='foo'" );
+ parse( "select distinct foo.component.name, foo.component.name from foo in class org.hibernate.test.Foo where foo.component.name='foo'" );
+ parse( "select distinct foo.component.name, foo.id from foo in class org.hibernate.test.Foo where foo.component.name='foo'" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.id=?" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.key=?" );
+ parse( "select foo.foo from foo in class org.hibernate.test.Foo where foo.string='fizard'" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.component.subcomponent.name='bar'" );
+ parse( "select foo.foo from foo in class org.hibernate.test.Foo where foo.foo.id=?" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.foo = ?" );
+ parse( "from bar in class org.hibernate.test.Bar where bar.string='a string' or bar.string='a string'" );
+ parse( "select foo.component.name, elements(foo.component.importantDates) from foo in class org.hibernate.test.Foo where foo.foo.id=?" );
+ parse( "select max(elements(foo.component.importantDates)) from foo in class org.hibernate.test.Foo group by foo.id" );
+ parse( "select foo.foo.foo.foo from foo in class org.hibernate.test.Foo, foo2 in class org.hibernate.test.Foo where foo = foo2.foo and not not ( not foo.string='fizard' ) and foo2.string between 'a' and (foo.foo.string) and ( foo2.string in ( 'fiz', 'blah') or 1=1 )" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.string='from BoogieDown -tinsel town =!@#$^&*())'" );
+ parse( "from foo in class org.hibernate.test.Foo where not foo.string='foo''bar'" ); // Added quote quote is an escape
+ parse( "from foo in class org.hibernate.test.Foo where foo.component.glarch.next is null" );
+ parse( " from bar in class org.hibernate.test.Bar where bar.baz.count=667 and bar.baz.count!=123 and not bar.baz.name='1-E-1'" );
+ parse( " from i in class org.hibernate.test.Bar where i.baz.name='Bazza'" );
+ parse( "select count(distinct foo.foo) from foo in class org.hibernate.test.Foo" );
+ parse( "select count(foo.foo.boolean) from foo in class org.hibernate.test.Foo" );
+ parse( "select count(*), foo.int from foo in class org.hibernate.test.Foo group by foo.int" );
+ parse( "select sum(foo.foo.int) from foo in class org.hibernate.test.Foo" );
+ parse( "select count(foo) from foo in class org.hibernate.test.Foo where foo.id=?" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.boolean = ?" );
+ parse( "select new Foo(fo.x) from org.hibernate.test.Fo fo" );
+ parse( "select new Foo(fo.integer) from org.hibernate.test.Foo fo" );
+ parse( "select new Foo(fo.x) from org.hibernate.test.Foo fo" );
+ parse( "select foo.long, foo.component.name, foo, foo.foo from foo in class org.hibernate.test.Foo" );
+ parse( "select avg(foo.float), max(foo.component.name), count(distinct foo.id) from foo in class org.hibernate.test.Foo" );
+ parse( "select foo.long, foo.component, foo, foo.foo from foo in class org.hibernate.test.Foo" );
+ parse( "from o in class org.hibernate.test.MoreStuff" );
+ parse( "from o in class org.hibernate.test.Many" );
+ parse( "from o in class org.hibernate.test.Fee" );
+ parse( "from o in class org.hibernate.test.Qux" );
+ parse( "from o in class org.hibernate.test.Y" );
+ parse( "from o in class org.hibernate.test.Fumm" );
+ parse( "from o in class org.hibernate.test.X" );
+ parse( "from o in class org.hibernate.test.Simple" );
+ parse( "from o in class org.hibernate.test.Location" );
+ parse( "from o in class org.hibernate.test.Holder" );
+ parse( "from o in class org.hibernate.test.Part" );
+ parse( "from o in class org.hibernate.test.Baz" );
+ parse( "from o in class org.hibernate.test.Vetoer" );
+ parse( "from o in class org.hibernate.test.Sortable" );
+ parse( "from o in class org.hibernate.test.Contained" );
+ parse( "from o in class org.hibernate.test.Stuff" );
+ parse( "from o in class org.hibernate.test.Immutable" );
+ parse( "from o in class org.hibernate.test.Container" );
+ parse( "from o in class org.hibernate.test.X$XX" );
+ parse( "from o in class org.hibernate.test.One" );
+ parse( "from o in class org.hibernate.test.Foo" );
+ parse( "from o in class org.hibernate.test.Fo" );
+ parse( "from o in class org.hibernate.test.Glarch" );
+ parse( "from o in class org.hibernate.test.Fum" );
+ parse( "from n in class org.hibernate.test.Holder" );
+ parse( "from n in class org.hibernate.test.Baz" );
+ parse( "from n in class org.hibernate.test.Bar" );
+ parse( "from n in class org.hibernate.test.Glarch" );
+ parse( "from n in class org.hibernate.test.Holder where n.name is not null" );
+ parse( "from n in class org.hibernate.test.Baz where n.name is not null" );
+ parse( "from n in class org.hibernate.test.Bar where n.name is not null" );
+ parse( "from n in class org.hibernate.test.Glarch where n.name is not null" );
+ parse( "from n in class org.hibernate.test.Holder" );
+ parse( "from n in class org.hibernate.test.Baz" );
+ parse( "from n in class org.hibernate.test.Bar" );
+ parse( "from n in class org.hibernate.test.Glarch" );
+ parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Holder where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Holder where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Holder where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Holder where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Baz where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Baz where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Baz where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Baz where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Bar where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Bar where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Bar where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Bar where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" );
+ parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" );
+ parse( "from n in class org.hibernate.test.Holder where n.name = :name" );
+ parse( "from o in class org.hibernate.test.MoreStuff" );
+ parse( "from o in class org.hibernate.test.Many" );
+ parse( "from o in class org.hibernate.test.Fee" );
+ parse( "from o in class org.hibernate.test.Qux" );
+ parse( "from o in class org.hibernate.test.Y" );
+ parse( "from o in class org.hibernate.test.Fumm" );
+ parse( "from o in class org.hibernate.test.X" );
+ parse( "from o in class org.hibernate.test.Simple" );
+ parse( "from o in class org.hibernate.test.Location" );
+ parse( "from o in class org.hibernate.test.Holder" );
+ parse( "from o in class org.hibernate.test.Part" );
+ parse( "from o in class org.hibernate.test.Baz" );
+ parse( "from o in class org.hibernate.test.Vetoer" );
+ parse( "from o in class org.hibernate.test.Sortable" );
+ parse( "from o in class org.hibernate.test.Contained" );
+ parse( "from o in class org.hibernate.test.Stuff" );
+ parse( "from o in class org.hibernate.test.Immutable" );
+ parse( "from o in class org.hibernate.test.Container" );
+ parse( "from o in class org.hibernate.test.X$XX" );
+ parse( "from o in class org.hibernate.test.One" );
+ parse( "from o in class org.hibernate.test.Foo" );
+ parse( "from o in class org.hibernate.test.Fo" );
+ parse( "from o in class org.hibernate.test.Glarch" );
+ parse( "from o in class org.hibernate.test.Fum" );
+ parse( "select baz.code, min(baz.count) from baz in class org.hibernate.test.Baz group by baz.code" );
+ parse( "selecT baz from baz in class org.hibernate.test.Baz where baz.stringDateMap['foo'] is not null or baz.stringDateMap['bar'] = ?" );
+ parse( "select baz from baz in class org.hibernate.test.Baz where baz.stringDateMap['now'] is not null" );
+ parse( "select baz from baz in class org.hibernate.test.Baz where baz.stringDateMap['now'] is not null and baz.stringDateMap['big bang'] < baz.stringDateMap['now']" );
+ parse( "select index(date) from org.hibernate.test.Baz baz join baz.stringDateMap date" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.integer not between 1 and 5 and foo.string not in ('cde', 'abc') and foo.string is not null and foo.integer<=3" );
+ parse( "from org.hibernate.test.Baz baz inner join baz.collectionComponent.nested.foos foo where foo.string is null" );
+ parse( "from org.hibernate.test.Baz baz inner join baz.fooSet where '1' in (from baz.fooSet foo where foo.string is not null)" );
+ parse( "from org.hibernate.test.Baz baz where 'a' in elements(baz.collectionComponent.nested.foos) and 1.0 in elements(baz.collectionComponent.nested.floats)" );
+ parse( "from org.hibernate.test.Foo foo join foo.foo where foo.foo in ('1','2','3')" );
+ parse( "select foo.foo from org.hibernate.test.Foo foo where foo.foo in ('1','2','3')" );
+ parse( "select foo.foo.string from org.hibernate.test.Foo foo where foo.foo in ('1','2','3')" );
+ parse( "select foo.foo.string from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3')" );
+ parse( "select foo.foo.long from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3')" );
+ parse( "select count(*) from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3') or foo.foo.long in (1,2,3)" );
+ parse( "select count(*) from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3') group by foo.foo.long" );
+ parse( "from org.hibernate.test.Foo foo1 left join foo1.foo foo2 left join foo2.foo where foo1.string is not null" );
+ parse( "from org.hibernate.test.Foo foo1 left join foo1.foo.foo where foo1.string is not null" );
+ parse( "from org.hibernate.test.Foo foo1 left join foo1.foo foo2 left join foo1.foo.foo foo3 where foo1.string is not null" );
+ parse( "select foo.formula from org.hibernate.test.Foo foo where foo.formula > 0" );
+ parse( "from org.hibernate.test.Foo as foo join foo.foo as foo2 where foo2.id >'a' or foo2.id <'a'" );
+ parse( "from org.hibernate.test.Holder" );
+ parse( "from org.hibernate.test.Baz baz left outer join fetch baz.manyToAny" );
+ parse( "from org.hibernate.test.Baz baz join baz.manyToAny" );
+ parse( "select baz from org.hibernate.test.Baz baz join baz.manyToAny a where index(a) = 0" );
+ parse( "select bar from org.hibernate.test.Bar bar where bar.baz.stringDateMap['now'] is not null" );
+ parse( "select bar from org.hibernate.test.Bar bar join bar.baz b where b.stringDateMap['big bang'] < b.stringDateMap['now'] and b.stringDateMap['now'] is not null" );
+ parse( "select bar from org.hibernate.test.Bar bar where bar.baz.stringDateMap['big bang'] < bar.baz.stringDateMap['now'] and bar.baz.stringDateMap['now'] is not null" );
+ parse( "select foo.string, foo.component, foo.id from org.hibernate.test.Bar foo" );
+ parse( "select elements(baz.components) from org.hibernate.test.Baz baz" );
+ parse( "select bc.name from org.hibernate.test.Baz baz join baz.components bc" );
+ parse( "from org.hibernate.test.Foo foo where foo.integer < 10 order by foo.string" );
+ parse( "from org.hibernate.test.Fee" );
+ parse( "from org.hibernate.test.Holder h join h.otherHolder oh where h.otherHolder.name = 'bar'" );
+ parse( "from org.hibernate.test.Baz baz join baz.fooSet foo join foo.foo.foo foo2 where foo2.string = 'foo'" );
+ parse( "from org.hibernate.test.Baz baz join baz.fooArray foo join foo.foo.foo foo2 where foo2.string = 'foo'" );
+ parse( "from org.hibernate.test.Baz baz join baz.stringDateMap date where index(date) = 'foo'" );
+ parse( "from org.hibernate.test.Baz baz join baz.topGlarchez g where index(g) = 'A'" );
+ parse( "select index(g) from org.hibernate.test.Baz baz join baz.topGlarchez g" );
+ parse( "from org.hibernate.test.Baz baz left join baz.stringSet" );
+ parse( "from org.hibernate.test.Baz baz join baz.stringSet str where str='foo'" );
+ parse( "from org.hibernate.test.Baz baz left join fetch baz.stringSet" );
+ parse( "from org.hibernate.test.Baz baz join baz.stringSet string where string='foo'" );
+ parse( "from org.hibernate.test.Baz baz inner join baz.components comp where comp.name='foo'" );
+ parse( "from org.hibernate.test.Glarch g inner join g.fooComponents comp where comp.fee is not null" );
+ parse( "from org.hibernate.test.Glarch g inner join g.fooComponents comp join comp.fee fee where fee.count > 0" );
+ parse( "from org.hibernate.test.Glarch g inner join g.fooComponents comp where comp.fee.count is not null" );
+ parse( "from org.hibernate.test.Baz baz left join fetch baz.fooBag" );
+ parse( "from org.hibernate.test.Glarch" );
+ parse( "from org.hibernate.test.Fee" );
+ parse( "from org.hibernate.test.Baz baz left join fetch baz.sortablez order by baz.name asc" );
+ parse( "from org.hibernate.test.Baz baz order by baz.name asc" );
+ parse( "from org.hibernate.test.Foo foo, org.hibernate.test.Baz baz left join fetch baz.fees" );
+ parse( "from org.hibernate.test.Foo foo, org.hibernate.test.Bar bar" );
+ parse( "from org.hibernate.test.Foo foo" );
+ parse( "from org.hibernate.test.Foo foo, org.hibernate.test.Bar bar, org.hibernate.test.Bar bar2" );
+ parse( "from org.hibernate.test.X x" );
+ parse( "from org.hibernate.test.Foo foo" );
+ parse( "select distinct foo from org.hibernate.test.Foo foo" );
+ parse( "from org.hibernate.test.Glarch g where g.multiple.glarch=g and g.multiple.count=12" );
+ parse( "from org.hibernate.test.Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like 'Bar %'" );
+ parse( "select bar, b from org.hibernate.test.Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like 'Bar%'" );
+ parse( "select bar, b from org.hibernate.test.Bar bar left join bar.baz baz left join baz.cascadingBars b where ( bar.name in (:nameList0_, :nameList1_, :nameList2_) or bar.name in (:nameList0_, :nameList1_, :nameList2_) ) and bar.string = :stringVal" );
+ parse( "select bar, b from org.hibernate.test.Bar bar inner join bar.baz baz inner join baz.cascadingBars b where bar.name like 'Bar%'" );
+ parse( "select bar, b from org.hibernate.test.Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like :name and b.name like :name" );
+ parse( "select bar from org.hibernate.test.Bar as bar where bar.x > ? or bar.short = 1 or bar.string = 'ff ? bb'" );
+ parse( "select bar from org.hibernate.test.Bar as bar where bar.string = ' ? ' or bar.string = '?'" );
+ parse( "from org.hibernate.test.Baz baz, baz.fooArray foo" );
+ parse( "from s in class org.hibernate.test.Stuff where s.foo.id = ? and s.id.id = ? and s.moreStuff.id.intId = ? and s.moreStuff.id.stringId = ?" );
+ parse( "from s in class org.hibernate.test.Stuff where s.foo.id = ? and s.id.id = ? and s.moreStuff.name = ?" );
+ parse( "from s in class org.hibernate.test.Stuff where s.foo.string is not null" );
+ parse( "from s in class org.hibernate.test.Stuff where s.foo > '0' order by s.foo" );
+ parse( "from ms in class org.hibernate.test.MoreStuff" );
+ parse( "from foo in class org.hibernate.test.Foo" );
+ parse( "from fee in class org.hibernate.test.Fee" );
+ parse( "select new Result(foo.string, foo.long, foo.integer) from foo in class org.hibernate.test.Foo" );
+ parse( "select new Result( baz.name, foo.long, count(elements(baz.fooArray)) ) from org.hibernate.test.Baz baz join baz.fooArray foo group by baz.name, foo.long" );
+ parse( "select new Result( baz.name, max(foo.long), count(foo) ) from org.hibernate.test.Baz baz join baz.fooArray foo group by baz.name" );
+ parse( "select max( elements(bar.baz.fooArray) ) from org.hibernate.test.Bar as bar" );
+ parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch join fetch baz.fooArray foo left join fetch foo.foo" );
+ parse( "select baz.name from org.hibernate.test.Bar bar inner join bar.baz baz inner join baz.fooSet foo where baz.name = bar.string" );
+ parse( "SELECT baz.name FROM org.hibernate.test.Bar AS bar INNER JOIN bar.baz AS baz INNER JOIN baz.fooSet AS foo WHERE baz.name = bar.string" );
+ parse( "select baz.name from org.hibernate.test.Bar bar join bar.baz baz left outer join baz.fooSet foo where baz.name = bar.string" );
+ parse( "select baz.name from org.hibernate.test.Bar bar, bar.baz baz, baz.fooSet foo where baz.name = bar.string" );
+ parse( "SELECT baz.name FROM org.hibernate.test.Bar AS bar, bar.baz AS baz, baz.fooSet AS foo WHERE baz.name = bar.string" );
+ parse( "select baz.name from org.hibernate.test.Bar bar left join bar.baz baz left join baz.fooSet foo where baz.name = bar.string" );
+ parse( "select foo.string from org.hibernate.test.Bar bar left join bar.baz.fooSet foo where bar.string = foo.string" );
+ parse( "select baz.name from org.hibernate.test.Bar bar left join bar.baz baz left join baz.fooArray foo where baz.name = bar.string" );
+ parse( "select foo.string from org.hibernate.test.Bar bar left join bar.baz.fooArray foo where bar.string = foo.string" );
+ parse( "select foo from bar in class org.hibernate.test.Bar inner join bar.baz as baz inner join baz.fooSet as foo" );
+ parse( "select foo from bar in class org.hibernate.test.Bar inner join bar.baz.fooSet as foo" );
+ parse( "select foo from bar in class org.hibernate.test.Bar, bar.baz as baz, baz.fooSet as foo" );
+ parse( "select foo from bar in class org.hibernate.test.Bar, bar.baz.fooSet as foo" );
+ parse( "from org.hibernate.test.Bar bar join bar.baz.fooArray foo" );
+ parse( "from bar in class org.hibernate.test.Bar, foo in elements( bar.baz.fooArray )" );
+ parse( "select one.id, elements(one.manies) from one in class org.hibernate.test.One" );
+ parse( "select max( elements(one.manies) ) from one in class org.hibernate.test.One" );
+ parse( "select one, elements(one.manies) from one in class org.hibernate.test.One" );
+ parse( "select one, max(elements(one.manies)) from one in class org.hibernate.test.One group by one" );
+ parse( "select elements(baz.fooArray) from baz in class org.hibernate.test.Baz where baz.id=?" );
+ parse( "select elements(baz.fooArray) from baz in class org.hibernate.test.Baz where baz.id=?" );
+ parse( "select indices(baz.fooArray) from baz in class org.hibernate.test.Baz where baz.id=?" );
+ parse( "select baz, max(elements(baz.timeArray)) from baz in class org.hibernate.test.Baz group by baz" );
+ parse( "select baz, baz.stringSet.size, count(distinct elements(baz.stringSet)), max(elements(baz.stringSet)) from baz in class org.hibernate.test.Baz group by baz" );
+ parse( "select max( elements(baz.timeArray) ) from baz in class org.hibernate.test.Baz where baz.id=?" );
+ parse( "select max(elements(baz.stringSet)) from baz in class org.hibernate.test.Baz where baz.id=?" );
+ parse( "select size(baz.stringSet) from baz in class org.hibernate.test.Baz where baz.id=?" );
+ parse( "from org.hibernate.test.Foo foo where foo.component.glarch.id is not null" );
+ parse( "from baz in class org.hibernate.test.Baz" );
+ parse( "select elements(baz.stringArray) from baz in class org.hibernate.test.Baz" );
+ parse( "from foo in class org.hibernate.test.Foo" );
+ parse( "select elements(baz.stringList) from baz in class org.hibernate.test.Baz" );
+ parse( "select count(*) from org.hibernate.test.Bar" );
+ parse( "select count(*) from b in class org.hibernate.test.Bar" );
+ parse( "from g in class org.hibernate.test.Glarch" );
+ parse( "select baz, baz from baz in class org.hibernate.test.Baz" );
+ parse( "select baz from baz in class org.hibernate.test.Baz order by baz" );
+ parse( "from bar in class org.hibernate.test.Bar" );
+ parse( "from g in class org.hibernate.test.Glarch" );
+ parse( "from f in class org.hibernate.test.Foo" );
+ parse( "from o in class org.hibernate.test.One" );
+ parse( "from q in class org.hibernate.test.Qux" );
+ parse( "select foo from foo in class org.hibernate.test.Foo where foo.string='foo bar'" );
+ parse( "from foo in class org.hibernate.test.Foo order by foo.string, foo.date" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.class='B'" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.class=Bar" );
+ parse( "select bar from bar in class org.hibernate.test.Bar, foo in class org.hibernate.test.Foo where bar.string = foo.string and not bar=foo" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.string='foo bar'" );
+ parse( "select foo from foo in class org.hibernate.test.Foo" );
+ parse( "from bar in class org.hibernate.test.Bar where bar.barString='bar bar'" );
+ parse( "from t in class org.hibernate.test.Trivial" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.date = ?" );
+ parse( "from o in class org.hibernate.test.MoreStuff" );
+ parse( "from o in class org.hibernate.test.Many" );
+ parse( "from o in class org.hibernate.test.Fee" );
+ parse( "from o in class org.hibernate.test.Qux" );
+ parse( "from o in class org.hibernate.test.Y" );
+ parse( "from o in class org.hibernate.test.Fumm" );
+ parse( "from o in class org.hibernate.test.X" );
+ parse( "from o in class org.hibernate.test.Simple" );
+ parse( "from o in class org.hibernate.test.Location" );
+ parse( "from o in class org.hibernate.test.Holder" );
+ parse( "from o in class org.hibernate.test.Part" );
+ parse( "from o in class org.hibernate.test.Baz" );
+ parse( "from o in class org.hibernate.test.Vetoer" );
+ parse( "from o in class org.hibernate.test.Sortable" );
+ parse( "from o in class org.hibernate.test.Contained" );
+ parse( "from o in class org.hibernate.test.Stuff" );
+ parse( "from o in class org.hibernate.test.Immutable" );
+ parse( "from o in class org.hibernate.test.Container" );
+ parse( "from o in class org.hibernate.test.X$XX" );
+ parse( "from o in class org.hibernate.test.One" );
+ parse( "from o in class org.hibernate.test.Foo" );
+ parse( "from o in class org.hibernate.test.Fo" );
+ parse( "from o in class org.hibernate.test.Glarch" );
+ parse( "from o in class org.hibernate.test.Fum" );
+ parse( "from q in class org.hibernate.test.Qux where q.stuff is null" );
+ parse( "from q in class org.hibernate.test.Qux where q.stuff=?" );
+ parse( "from q in class org.hibernate.test.Qux" );
+ parse( "from g in class org.hibernate.test.Glarch where g.version=2" );
+ parse( "from g in class org.hibernate.test.Glarch where g.next is not null" );
+ parse( "from g in class org.hibernate.test.Glarch order by g.order asc" );
+ parse( "from foo in class org.hibernate.test.Foo order by foo.string asc" );
+ parse( "select parent, child from parent in class org.hibernate.test.Foo, child in class org.hibernate.test.Foo where parent.foo = child" );
+ parse( "select count(distinct child.id), count(distinct parent.id) from parent in class org.hibernate.test.Foo, child in class org.hibernate.test.Foo where parent.foo = child" );
+ parse( "select child.id, parent.id, child.long from parent in class org.hibernate.test.Foo, child in class org.hibernate.test.Foo where parent.foo = child" );
+ parse( "select child.id, parent.id, child.long, child, parent.foo from parent in class org.hibernate.test.Foo, child in class org.hibernate.test.Foo where parent.foo = child" );
+ parse( "select parent, child from parent in class org.hibernate.test.Foo, child in class org.hibernate.test.Foo where parent.foo = child and parent.string='a string'" );
+ parse( "from fee in class org.hibernate.test.Fee" );
+ parse( "from org.hibernate.test.Foo foo where foo.custom.s1 = 'one'" );
+ parse( "from im in class org.hibernate.test.Immutable where im = ?" );
+ parse( "from foo in class org.hibernate.test.Foo" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.char='X'" );
+ parse( "select elements(baz.stringArray) from baz in class org.hibernate.test.Baz" );
+ parse( "select distinct elements(baz.stringArray) from baz in class org.hibernate.test.Baz" );
+ parse( "select elements(baz.fooArray) from baz in class org.hibernate.test.Baz" );
+ parse( "from foo in class org.hibernate.test.Fo" );
+ parse( "from foo in class org.hibernate.test.Foo where foo.dependent.qux.foo.string = 'foo2'" );
+ parse( "from org.hibernate.test.Bar bar where bar.object.id = ? and bar.object.class = ?" );
+ parse( "select one from org.hibernate.test.One one, org.hibernate.test.Bar bar where bar.object.id = one.id and bar.object.class = 'O'" );
+ parse( "from l in class org.hibernate.test.Location where l.countryCode = 'AU' and l.description='foo bar'" );
+ parse( "from org.hibernate.test.Bar bar" );
+ parse( "From org.hibernate.test.Bar bar" );
+ parse( "From org.hibernate.test.Foo foo" );
+ parse( "from o in class org.hibernate.test.Baz" );
+ parse( "from o in class org.hibernate.test.Foo" );
+ parse( "from f in class org.hibernate.test.Foo" );
+ parse( "select fum.id from fum in class org.hibernate.test.Fum where not fum.fum='FRIEND'" );
+ parse( "select fum.id from fum in class org.hibernate.test.Fum where not fum.fum='FRIEND'" );
+ parse( "from fum in class org.hibernate.test.Fum where not fum.fum='FRIEND'" );
+ parse( "from fo in class org.hibernate.test.Fo where fo.id.string like 'an instance of fo'" );
+ parse( "from org.hibernate.test.Inner" );
+ parse( "from org.hibernate.test.Outer o where o.id.detailId = ?" );
+ parse( "from org.hibernate.test.Outer o where o.id.master.id.sup.dudu is not null" );
+ parse( "from org.hibernate.test.Outer o where o.id.master.id.sup.id.akey is not null" );
+ parse( "select o.id.master.id.sup.dudu from org.hibernate.test.Outer o where o.id.master.id.sup.dudu is not null" );
+ parse( "select o.id.master.id.sup.id.akey from org.hibernate.test.Outer o where o.id.master.id.sup.id.akey is not null" );
+ parse( "from org.hibernate.test.Outer o where o.id.master.bla = ''" );
+ parse( "from org.hibernate.test.Outer o where o.id.master.id.one = ''" );
+ parse( "from org.hibernate.test.Inner inn where inn.id.bkey is not null and inn.backOut.id.master.id.sup.id.akey > 'a'" );
+ parse( "from org.hibernate.test.Outer as o left join o.id.master m left join m.id.sup where o.bubu is not null" );
+ parse( "from org.hibernate.test.Outer as o left join o.id.master.id.sup s where o.bubu is not null" );
+ parse( "from org.hibernate.test.Outer as o left join o.id.master m left join o.id.master.id.sup s where o.bubu is not null" );
+ parse( "select fum1.fo from fum1 in class org.hibernate.test.Fum where fum1.fo.fum is not null" );
+ parse( "from fum1 in class org.hibernate.test.Fum where fum1.fo.fum is not null order by fum1.fo.fum" );
+ parse( "select elements(fum1.friends) from fum1 in class org.hibernate.test.Fum" );
+ parse( "from fum1 in class org.hibernate.test.Fum, fr in elements( fum1.friends )" );
+ parse( "select new Jay(eye) from org.hibernate.test.Eye eye" );
+ parse( "from org.hibernate.test.Category cat where cat.name='new foo'" );
+ parse( "from org.hibernate.test.Category cat where cat.name='new sub'" );
+ parse( "from org.hibernate.test.Up up order by up.id2 asc" );
+ parse( "from org.hibernate.test.Down down" );
+ parse( "from org.hibernate.test.Up up" );
+ parse( "from m in class org.hibernate.test.Master" );
+ parse( "from s in class org.hibernate.test.Several" );
+ parse( "from s in class org.hibernate.test.Single" );
+ parse( "\n" +
+ " from d in class \n" +
+ " org.hibernate.test.Detail\n" +
+ " " );
+ parse( "from c in class org.hibernate.test.Category where c.name = org.hibernate.test.Category.ROOT_CATEGORY" );
+ parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where c.oneToMany[2] = s" );
+ parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where c.manyToMany[2] = s" );
+ parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where s = c.oneToMany[2]" );
+ parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where s = c.manyToMany[2]" );
+ parse( "select c from c in class org.hibernate.test.Container where c.oneToMany[0].name = 's'" );
+ parse( "select c from c in class org.hibernate.test.Container where c.manyToMany[0].name = 's'" );
+ parse( "select c from c in class org.hibernate.test.Container where 's' = c.oneToMany[2 - 2].name" );
+ parse( "select c from c in class org.hibernate.test.Container where 's' = c.manyToMany[(3+1)/4-1].name" );
+ parse( "select c from c in class org.hibernate.test.Container where c.manyToMany[ maxindex(c.manyToMany) ].count = 2" );
+ parse( "select c from c in class org.hibernate.test.Container where c.oneToMany[ c.manyToMany[0].count ].name = 's'" );
+ parse( "select c from org.hibernate.test.Container c where c.manyToMany[ c.oneToMany[0].count ].name = 's'" );
+ parse( "select count(comp.name) from org.hibernate.test.Container c join c.components comp" );
+ parse( "from org.hibernate.test.Parent p left join fetch p.child" );
+ parse( "from org.hibernate.test.Parent p join p.child c where c.x > 0" );
+ parse( "from org.hibernate.test.Child c join c.parent p where p.x > 0" );
+ parse( "from org.hibernate.test.Child" );
+ parse( "from org.hibernate.test.MoreStuff" );
+ parse( "from org.hibernate.test.Many" );
+ parse( "from org.hibernate.test.Fee" );
+ parse( "from org.hibernate.test.Qux" );
+ parse( "from org.hibernate.test.Fumm" );
+ parse( "from org.hibernate.test.Parent" );
+ parse( "from org.hibernate.test.Simple" );
+ parse( "from org.hibernate.test.Holder" );
+ parse( "from org.hibernate.test.Part" );
+ parse( "from org.hibernate.test.Baz" );
+ parse( "from org.hibernate.test.Vetoer" );
+ parse( "from org.hibernate.test.Sortable" );
+ parse( "from org.hibernate.test.Contained" );
+ parse( "from org.hibernate.test.Circular" );
+ parse( "from org.hibernate.test.Stuff" );
+ parse( "from org.hibernate.test.Immutable" );
+ parse( "from org.hibernate.test.Container" );
+ parse( "from org.hibernate.test.One" );
+ parse( "from org.hibernate.test.Foo" );
+ parse( "from org.hibernate.test.Fo" );
+ parse( "from org.hibernate.test.Glarch" );
+ parse( "from org.hibernate.test.Fum" );
+ parse( "from org.hibernate.test.Glarch g" );
+ parse( "from org.hibernate.test.Part" );
+ parse( "from org.hibernate.test.Baz baz join baz.parts" );
+ parse( "from c in class org.hibernate.test.Child where c.parent.count=66" );
+ parse( "from org.hibernate.te...
[truncated message content] |