1 package org.hibernate.test.hql; 3 4 5 import java.io.ByteArrayOutputStream ; 6 import java.io.PrintStream ; 7 8 import junit.framework.Test; 9 import junit.framework.TestCase; 10 import junit.framework.TestSuite; 11 12 import org.apache.commons.logging.Log; 13 import org.apache.commons.logging.LogFactory; 14 import org.hibernate.hql.ast.HqlParser; 15 import org.hibernate.hql.ast.util.ASTPrinter; 16 17 import antlr.RecognitionException; 18 import antlr.TokenStreamException; 19 import antlr.collections.AST; 20 21 25 public class HqlParserTest extends TestCase { 26 29 private static final Log log = LogFactory.getLog( HqlParserTest.class ); 30 31 36 public HqlParserTest(String name) { 37 super( name ); 38 } 39 40 public void testUnion() throws Exception { 41 parse("from Animal a where a in (from Cat union from Dog) "); 42 } 43 44 47 public void testDocoExamples92() throws Exception { 48 parse( "from eg.Cat" ); 49 parse( "from eg.Cat as cat" ); 50 parse( "from eg.Cat cat" ); 51 parse( "from Formula, Parameter" ); 52 parse( "from Formula as form, Parameter as param" ); 53 } 54 55 58 public void testDocoExamples93() throws Exception { 59 parse( "from eg.Cat as cat inner join cat.mate as mate left outer join cat.kittens as kitten" ); 60 parse( "from eg.Cat as cat left join cat.mate.kittens as kittens" ); 61 parse( "from Formula form full join form.parameter param" ); 62 parse( "from eg.Cat as cat join cat.mate as mate left join cat.kittens as kitten" ); 63 parse( "from eg.Cat as cat\ninner join fetch cat.mate\nleft join fetch cat.kittens" ); 64 } 65 66 69 public void testDocoExamples94() throws Exception { 70 parse( "select mate from eg.Cat as cat inner join cat.mate as mate" ); 71 parse( "select cat.mate from eg.Cat cat" ); 72 parse( "select elements(cat.kittens) from eg.Cat cat" ); 73 parse( "select cat.name from eg.DomesticCat cat where cat.name like 'fri%'" ); 74 parse( "select cust.name.firstName from Customer as cust" ); 75 parse( "select mother, offspr, mate.name from eg.DomesticCat\n" 76 + " as mother inner join mother.mate as mate left outer join\n" 77 + "mother.kittens as offspr" ); 78 parse( "select new Family(mother, mate, offspr)\n" 79 + "from eg.DomesticCat as mother\n" 80 + "join mother.mate as mate\n" 81 + "left join mother.kittens as offspr\n" ); 82 } 83 84 87 public void testDocoExamples95() throws Exception { 88 parse( "select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)\n" 89 + "from eg.Cat cat" ); 90 parse( "select cat, count( elements(cat.kittens) )\n" 91 + " from eg.Cat cat group by cat" ); 92 parse( "select distinct cat.name from eg.Cat cat" ); 93 parse( "select count(distinct cat.name), count(cat) from eg.Cat cat" ); 94 } 95 96 99 public void testDocoExamples96() throws Exception { 100 parse( "from eg.Cat as cat" ); 101 parse( "from java.lang.Object o" ); 102 parse( "from eg.Named n, eg.Named m where n.name = m.name" ); 103 } 104 105 108 public void testDocoExamples97() throws Exception { 109 parse( "from eg.Cat as cat where cat.name='Fritz'" ); 110 parse( "select foo\n" 111 + "from eg.Foo foo, eg.Bar bar\n" 112 + "where foo.startDate = bar.date\n" ); 113 parse( "from eg.Cat cat where cat.mate.name is not null" ); 114 parse( "from eg.Cat cat, eg.Cat rival where cat.mate = rival.mate" ); 115 parse( "select cat, mate\n" 116 + "from eg.Cat cat, eg.Cat mate\n" 117 + "where cat.mate = mate" ); 118 parse( "from eg.Cat as cat where cat.id = 123" ); 119 parse( "from eg.Cat as cat where cat.mate.id = 69" ); 120 parse( "from bank.Person person\n" 121 + "where person.id.country = 'AU'\n" 122 + "and person.id.medicareNumber = 123456" ); 123 parse( "from bank.Account account\n" 124 + "where account.owner.id.country = 'AU'\n" 125 + "and account.owner.id.medicareNumber = 123456" ); 126 parse( "from eg.Cat cat where cat.class = eg.DomesticCat" ); 127 parse( "from eg.AuditLog log, eg.Payment payment\n" 128 + "where log.item.class = 'eg.Payment' and log.item.id = payment.id" ); 129 } 130 131 134 public void testDocoExamples98() throws Exception { 135 parse( "from eg.DomesticCat cat where cat.name between 'A' and 'B'" ); 136 parse( "from eg.DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' )" ); 137 parse( "from eg.DomesticCat cat where cat.name not between 'A' and 'B'" ); 138 parse( "from eg.DomesticCat cat where cat.name not in ( 'Foo', 'Bar', 'Baz' )" ); 139 parse( "from eg.Cat cat where cat.kittens.size > 0" ); 140 parse( "from eg.Cat cat where size(cat.kittens) > 0" ); 141 parse( "from Order ord where maxindex(ord.items) > 100" ); 148 parse( "from Order ord where minelement(ord.items) > 10000" ); 149 150 parse( "select mother from eg.Cat as mother, eg.Cat as kit\n" 151 + "where kit in elements(foo.kittens)" ); 152 parse( "select p from eg.NameList list, eg.Person p\n" 153 + "where p.name = some elements(list.names)" ); 154 parse( "from eg.Cat cat where exists elements(cat.kittens)" ); 155 parse( "from eg.Player p where 3 > all elements(p.scores)" ); 156 parse( "from eg.Show show where 'fizard' in indices(show.acts)" ); 157 158 168 parse( "from Order ord where ord.items[0].id = 1234" ); 169 parse( "select person from Person person, Calendar calendar\n" 170 + "where calendar.holidays['national day'] = person.birthDay\n" 171 + "and person.nationality.calendar = calendar" ); 172 parse( "select item from Item item, Order ord\n" 173 + "where ord.items[ ord.deliveredItemIndices[0] ] = item and ord.id = 11" ); 174 parse( "select item from Item item, Order ord\n" 175 + "where ord.items[ maxindex(ord.items) ] = item and ord.id = 11" ); 176 177 parse( "select item from Item item, Order ord\n" 178 + "where ord.items[ size(ord.items) - 1 ] = item" ); 179 180 parse( "from eg.DomesticCat cat where upper(cat.name) like 'FRI%'" ); 181 182 parse( "select cust from Product prod, Store store\n" 183 + "inner join store.customers cust\n" 184 + "where prod.name = 'widget'\n" 185 + "and store.location.name in ( 'Melbourne', 'Sydney' )\n" 186 + "and prod = all elements(cust.currentOrder.lineItems)" ); 187 188 } 189 190 public void testDocoExamples99() throws Exception { 191 parse( "from eg.DomesticCat cat\n" 192 + "order by cat.name asc, cat.weight desc, cat.birthdate" ); 193 } 194 195 public void testDocoExamples910() throws Exception { 196 parse( "select cat.color, sum(cat.weight), count(cat)\n" 197 + "from eg.Cat cat group by cat.color" ); 198 parse( "select foo.id, avg( elements(foo.names) ), max( indices(foo.names) )\n" 199 + "from eg.Foo foo group by foo.id" ); 200 parse( "select cat.color, sum(cat.weight), count(cat)\n" 201 + "from eg.Cat cat group by cat.color\n" 202 + "having cat.color in (eg.Color.TABBY, eg.Color.BLACK)" ); 203 parse( "select cat from eg.Cat cat join cat.kittens kitten\n" 204 + "group by cat having avg(kitten.weight) > 100\n" 205 + "order by count(kitten) asc, sum(kitten.weight) desc" ); 206 } 207 208 public void testDocoExamples911() throws Exception { 209 parse( "from eg.Cat as fatcat where fatcat.weight > (\n" 210 + "select avg(cat.weight) from eg.DomesticCat cat)" ); 211 parse( "from eg.DomesticCat as cat where cat.name = some (\n" 212 + "select name.nickName from eg.Name as name)\n" ); 213 parse( "from eg.Cat as cat where not exists (\n" 214 + "from eg.Cat as mate where mate.mate = cat)" ); 215 parse( "from eg.DomesticCat as cat where cat.name not in (\n" 216 + "select name.nickName from eg.Name as name)" ); 217 } 218 219 public void testDocoExamples912() throws Exception { 220 parse( "select ord.id, sum(price.amount), count(item)\n" 221 + "from Order as ord join ord.lineItems as item\n" 222 + "join item.product as product, Catalog as catalog\n" 223 + "join catalog.prices as price\n" 224 + "where ord.paid = false\n" 225 + "and ord.customer = :customer\n" 226 + "and price.product = product\n" 227 + "and catalog.effectiveDate < sysdate\n" 228 + "and catalog.effectiveDate >= all (\n" 229 + "select cat.effectiveDate from Catalog as cat where cat.effectiveDate < sysdate)\n" 230 + "group by ord\n" 231 + "having sum(price.amount) > :minAmount\n" 232 + "order by sum(price.amount) desc" ); 233 234 parse( "select ord.id, sum(price.amount), count(item)\n" 235 + "from Order as ord join ord.lineItems as item join item.product as product,\n" 236 + "Catalog as catalog join catalog.prices as price\n" 237 + "where ord.paid = false and ord.customer = :customer\n" 238 + "and price.product = product and catalog = :currentCatalog\n" 239 + "group by ord having sum(price.amount) > :minAmount\n" 240 + "order by sum(price.amount) desc" ); 241 242 parse( "select count(payment), status.name \n" 243 + "from Payment as payment \n" 244 + " join payment.currentStatus as status\n" 245 + " join payment.statusChanges as statusChange\n" 246 + "where payment.status.name <> PaymentStatus.AWAITING_APPROVAL\n" 247 + " or (\n" 248 + " statusChange.timeStamp = ( \n" 249 + " select max(change.timeStamp) \n" 250 + " from PaymentStatusChange change \n" 251 + " where change.payment = payment\n" 252 + " )\n" 253 + " and statusChange.user <> :currentUser\n" 254 + " )\n" 255 + "group by status.name, status.sortOrder\n" 256 + "order by status.sortOrder" ); 257 parse( "select count(payment), status.name \n" 258 + "from Payment as payment\n" 259 + " join payment.currentStatus as status\n" 260 + "where payment.status.name <> PaymentStatus.AWAITING_APPROVAL\n" 261 + " or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :currentUser\n" 262 + "group by status.name, status.sortOrder\n" 263 + "order by status.sortOrder" ); 264 parse( "select account, payment\n" 265 + "from Account as account\n" 266 + " left outer join account.payments as payment\n" 267 + "where :currentUser in elements(account.holder.users)\n" 268 + " and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID)\n" 269 + "order by account.type.sortOrder, account.accountNumber, payment.dueDate" ); 270 parse( "select account, payment\n" 271 + "from Account as account\n" 272 + " join account.holder.users as user\n" 273 + " left outer join account.payments as payment\n" 274 + "where :currentUser = user\n" 275 + " and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID)\n" 276 + "order by account.type.sortOrder, account.accountNumber, payment.dueDate" ); 277 } 278 279 public void testExamples1() throws Exception { 280 parse( "select new org.hibernate.test.S(s.count, s.address)\n" 281 + "from s in class Simple" ); 282 parse( "select s.name, sysdate, trunc(s.pay), round(s.pay) from s in class Simple" ); 283 parse( "select round(s.pay, 2) from s" ); 284 parse( "select abs(round(s.pay)) from s in class Simple" ); 285 parse( "select trunc(round(sysdate)) from s in class Simple" ); 286 } 287 288 public void testArrayExpr() throws Exception { 289 parse( "from Order ord where ord.items[0].id = 1234" ); 290 } 291 292 public void testMultipleActualParameters() throws Exception { 293 parse( "select round(s.pay, 2) from s" ); 294 } 295 296 public void testMultipleFromClasses() throws Exception { 297 parse( "FROM eg.mypackage.Cat qat, com.toadstool.Foo f" ); 298 parse( "FROM eg.mypackage.Cat qat, org.jabberwocky.Dipstick" ); 299 } 300 301 public void testFromWithJoin() throws Exception { 302 parse( "FROM eg.mypackage.Cat qat, com.toadstool.Foo f join net.sf.blurb.Blurb" ); 303 parse( "FROM eg.mypackage.Cat qat left join com.multijoin.JoinORama , com.toadstool.Foo f join net.sf.blurb.Blurb" ); 304 } 305 306 public void testSelect() throws Exception { 307 parse( "SELECT f FROM eg.mypackage.Cat qat, com.toadstool.Foo f join net.sf.blurb.Blurb" ); 308 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" ); 309 parse( "SELECT count(*) FROM eg.mypackage.Cat qat" ); 310 parse( "SELECT avg(qat.weight) FROM eg.mypackage.Cat qat" ); 311 } 312 313 public void testWhere() throws Exception { 314 parse( "FROM eg.mypackage.Cat qat where qat.name like '%fluffy%' or qat.toes > 5" ); 315 parse( "FROM eg.mypackage.Cat qat where not qat.name like '%fluffy%' or qat.toes > 5" ); 316 parse( "FROM eg.mypackage.Cat qat where not qat.name not like '%fluffy%'" ); 317 parse( "FROM eg.mypackage.Cat qat where qat.name in ('crater','bean','fluffy')" ); 318 parse( "FROM eg.mypackage.Cat qat where qat.name not in ('crater','bean','fluffy')" ); 319 parse( "from Animal an where sqrt(an.bodyWeight)/2 > 10" ); 320 parse( "from Animal an where (an.bodyWeight > 10 and an.bodyWeight < 100) or an.bodyWeight is null" ); 321 } 322 323 public void testGroupBy() throws Exception { 324 parse( "FROM eg.mypackage.Cat qat group by qat.breed" ); 325 parse( "FROM eg.mypackage.Cat qat group by qat.breed, qat.eyecolor" ); 326 } 327 328 public void testOrderBy() throws Exception { 329 parse( "FROM eg.mypackage.Cat qat order by avg(qat.toes)" ); 330 parse( "from Animal an order by sqrt(an.bodyWeight)/2" ); 331 } 332 333 public void testDoubleLiteral() throws Exception { 334 parse( "from eg.Cat as tinycat where fatcat.weight < 3.1415" ); 335 parse( "from eg.Cat as enormouscat where fatcat.weight > 3.1415e3" ); 336 } 337 338 public void testComplexConstructor() throws Exception { 339 parse( "select new Foo(count(bar)) from bar" ); 340 parse( "select new Foo(count(bar),(select count(*) from doofus d where d.gob = 'fat' )) from bar" ); 341 } 342 343 344 public void testInNotIn() throws Exception { 345 parse( "from foo where foo.bar in ('a' , 'b', 'c')" ); 346 parse( "from foo where foo.bar not in ('a' , 'b', 'c')" ); 347 } 348 349 public void testOperatorPrecedence() throws Exception { 350 parse( "from foo where foo.bar = 123 + foo.baz * foo.not" ); 351 parse( "from foo where foo.bar like 'testzzz' || foo.baz or foo.bar in ('duh', 'gob')" ); 352 } 353 354 359 public void testUnitTestHql() throws Exception { 360 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" ); 361 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" ); 362 parse( "select foo from foo in class org.hibernate.test.Foo order by foo.dependent.id, foo.dependent.fi" ); 363 parse( "SELECT one FROM one IN CLASS org.hibernate.test.One ORDER BY one.value ASC" ); 364 parse( "SELECT many.one FROM many IN CLASS org.hibernate.test.Many ORDER BY many.one.value ASC, many.one.id" ); 365 parse( "select foo.id from org.hibernate.test.Foo foo where foo.joinedProp = 'foo'" ); 366 parse( "from org.hibernate.test.Foo foo inner join fetch foo.foo" ); 367 parse( "from org.hibernate.test.Baz baz left outer join fetch baz.fooToGlarch" ); 368 parse( "select foo.foo.foo.string from foo in class org.hibernate.test.Foo where foo.foo = 'bar'" ); 369 parse( "select foo.foo.foo.foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo = 'bar'" ); 370 parse( "select foo.foo.foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo.foo.string = 'bar'" ); 371 parse( "select foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'" ); 372 parse( "select foo.string from foo in class org.hibernate.test.Foo where foo.foo.foo.foo.string = 'a' and foo.foo.string = 'b'" ); 373 parse( "from org.hibernate.test.Foo as foo where foo.component.glarch.name is not null" ); 374 parse( "from org.hibernate.test.Foo as foo left outer join foo.component.glarch as glarch where glarch.name = 'foo'" ); 375 parse( "from org.hibernate.test.Foo" ); 376 parse( "from org.hibernate.test.Foo foo left outer join foo.foo" ); 377 parse( "from org.hibernate.test.Foo, org.hibernate.test.Bar" ); 378 parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch, org.hibernate.test.Bar bar join bar.foo" ); 379 parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch join baz.fooSet" ); 380 parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch join fetch baz.fooSet foo left join fetch foo.foo" ); 381 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" ); 382 parse( "from foo in class org.hibernate.test.Foo where foo.string='osama bin laden' order by foo.string asc, foo.component.count desc" ); 383 parse( "select foo.foo from foo in class org.hibernate.test.Foo" ); 384 parse( "from foo in class org.hibernate.test.Foo where foo.component.count is null order by foo.component.count" ); 385 parse( "from foo in class org.hibernate.test.Foo where foo.component.name='foo'" ); 386 parse( "select distinct foo.component.name, foo.component.name from foo in class org.hibernate.test.Foo where foo.component.name='foo'" ); 387 parse( "select distinct foo.component.name, foo.id from foo in class org.hibernate.test.Foo where foo.component.name='foo'" ); 388 parse( "from foo in class org.hibernate.test.Foo where foo.id=?" ); 389 parse( "from foo in class org.hibernate.test.Foo where foo.key=?" ); 390 parse( "select foo.foo from foo in class org.hibernate.test.Foo where foo.string='fizard'" ); 391 parse( "from foo in class org.hibernate.test.Foo where foo.component.subcomponent.name='bar'" ); 392 parse( "select foo.foo from foo in class org.hibernate.test.Foo where foo.foo.id=?" ); 393 parse( "from foo in class org.hibernate.test.Foo where foo.foo = ?" ); 394 parse( "from bar in class org.hibernate.test.Bar where bar.string='a string' or bar.string='a string'" ); 395 parse( "select foo.component.name, elements(foo.component.importantDates) from foo in class org.hibernate.test.Foo where foo.foo.id=?" ); 396 parse( "select max(elements(foo.component.importantDates)) from foo in class org.hibernate.test.Foo group by foo.id" ); 397 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 )" ); 398 parse( "from foo in class org.hibernate.test.Foo where foo.string='from BoogieDown -tinsel town =!@#$^&*())'" ); 399 parse( "from foo in class org.hibernate.test.Foo where not foo.string='foo''bar'" ); parse( "from foo in class org.hibernate.test.Foo where foo.component.glarch.next is null" ); 401 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'" ); 402 parse( " from i in class org.hibernate.test.Bar where i.baz.name='Bazza'" ); 403 parse( "select count(distinct foo.foo) from foo in class org.hibernate.test.Foo" ); 404 parse( "select count(foo.foo.boolean) from foo in class org.hibernate.test.Foo" ); 405 parse( "select count(*), foo.int from foo in class org.hibernate.test.Foo group by foo.int" ); 406 parse( "select sum(foo.foo.int) from foo in class org.hibernate.test.Foo" ); 407 parse( "select count(foo) from foo in class org.hibernate.test.Foo where foo.id=?" ); 408 parse( "from foo in class org.hibernate.test.Foo where foo.boolean = ?" ); 409 parse( "select new Foo(fo.x) from org.hibernate.test.Fo fo" ); 410 parse( "select new Foo(fo.integer) from org.hibernate.test.Foo fo" ); 411 parse( "select new Foo(fo.x) from org.hibernate.test.Foo fo" ); 412 parse( "select foo.long, foo.component.name, foo, foo.foo from foo in class org.hibernate.test.Foo" ); 413 parse( "select avg(foo.float), max(foo.component.name), count(distinct foo.id) from foo in class org.hibernate.test.Foo" ); 414 parse( "select foo.long, foo.component, foo, foo.foo from foo in class org.hibernate.test.Foo" ); 415 parse( "from o in class org.hibernate.test.MoreStuff" ); 416 parse( "from o in class org.hibernate.test.Many" ); 417 parse( "from o in class org.hibernate.test.Fee" ); 418 parse( "from o in class org.hibernate.test.Qux" ); 419 parse( "from o in class org.hibernate.test.Y" ); 420 parse( "from o in class org.hibernate.test.Fumm" ); 421 parse( "from o in class org.hibernate.test.X" ); 422 parse( "from o in class org.hibernate.test.Simple" ); 423 parse( "from o in class org.hibernate.test.Location" ); 424 parse( "from o in class org.hibernate.test.Holder" ); 425 parse( "from o in class org.hibernate.test.Part" ); 426 parse( "from o in class org.hibernate.test.Baz" ); 427 parse( "from o in class org.hibernate.test.Vetoer" ); 428 parse( "from o in class org.hibernate.test.Sortable" ); 429 parse( "from o in class org.hibernate.test.Contained" ); 430 parse( "from o in class org.hibernate.test.Stuff" ); 431 parse( "from o in class org.hibernate.test.Immutable" ); 432 parse( "from o in class org.hibernate.test.Container" ); 433 parse( "from o in class org.hibernate.test.X$XX" ); 434 parse( "from o in class org.hibernate.test.One" ); 435 parse( "from o in class org.hibernate.test.Foo" ); 436 parse( "from o in class org.hibernate.test.Fo" ); 437 parse( "from o in class org.hibernate.test.Glarch" ); 438 parse( "from o in class org.hibernate.test.Fum" ); 439 parse( "from n in class org.hibernate.test.Holder" ); 440 parse( "from n in class org.hibernate.test.Baz" ); 441 parse( "from n in class org.hibernate.test.Bar" ); 442 parse( "from n in class org.hibernate.test.Glarch" ); 443 parse( "from n in class org.hibernate.test.Holder where n.name is not null" ); 444 parse( "from n in class org.hibernate.test.Baz where n.name is not null" ); 445 parse( "from n in class org.hibernate.test.Bar where n.name is not null" ); 446 parse( "from n in class org.hibernate.test.Glarch where n.name is not null" ); 447 parse( "from n in class org.hibernate.test.Holder" ); 448 parse( "from n in class org.hibernate.test.Baz" ); 449 parse( "from n in class org.hibernate.test.Bar" ); 450 parse( "from n in class org.hibernate.test.Glarch" ); 451 parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Holder where n0.name = n1.name" ); 452 parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Holder where n0.name = n1.name" ); 453 parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Holder where n0.name = n1.name" ); 454 parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Holder where n0.name = n1.name" ); 455 parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Baz where n0.name = n1.name" ); 456 parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Baz where n0.name = n1.name" ); 457 parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Baz where n0.name = n1.name" ); 458 parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Baz where n0.name = n1.name" ); 459 parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Bar where n0.name = n1.name" ); 460 parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Bar where n0.name = n1.name" ); 461 parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Bar where n0.name = n1.name" ); 462 parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Bar where n0.name = n1.name" ); 463 parse( "from n0 in class org.hibernate.test.Holder, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" ); 464 parse( "from n0 in class org.hibernate.test.Baz, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" ); 465 parse( "from n0 in class org.hibernate.test.Bar, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" ); 466 parse( "from n0 in class org.hibernate.test.Glarch, n1 in class org.hibernate.test.Glarch where n0.name = n1.name" ); 467 parse( "from n in class org.hibernate.test.Holder where n.name = :name" ); 468 parse( "from o in class org.hibernate.test.MoreStuff" ); 469 parse( "from o in class org.hibernate.test.Many" ); 470 parse( "from o in class org.hibernate.test.Fee" ); 471 parse( "from o in class org.hibernate.test.Qux" ); 472 parse( "from o in class org.hibernate.test.Y" ); 473 parse( "from o in class org.hibernate.test.Fumm" ); 474 parse( "from o in class org.hibernate.test.X" ); 475 parse( "from o in class org.hibernate.test.Simple" ); 476 parse( "from o in class org.hibernate.test.Location" ); 477 parse( "from o in class org.hibernate.test.Holder" ); 478 parse( "from o in class org.hibernate.test.Part" ); 479 parse( "from o in class org.hibernate.test.Baz" ); 480 parse( "from o in class org.hibernate.test.Vetoer" ); 481 parse( "from o in class org.hibernate.test.Sortable" ); 482 parse( "from o in class org.hibernate.test.Contained" ); 483 parse( "from o in class org.hibernate.test.Stuff" ); 484 parse( "from o in class org.hibernate.test.Immutable" ); 485 parse( "from o in class org.hibernate.test.Container" ); 486 parse( "from o in class org.hibernate.test.X$XX" ); 487 parse( "from o in class org.hibernate.test.One" ); 488 parse( "from o in class org.hibernate.test.Foo" ); 489 parse( "from o in class org.hibernate.test.Fo" ); 490 parse( "from o in class org.hibernate.test.Glarch" ); 491 parse( "from o in class org.hibernate.test.Fum" ); 492 parse( "select baz.code, min(baz.count) from baz in class org.hibernate.test.Baz group by baz.code" ); 493 parse( "selecT baz from baz in class org.hibernate.test.Baz where baz.stringDateMap['foo'] is not null or baz.stringDateMap['bar'] = ?" ); 494 parse( "select baz from baz in class org.hibernate.test.Baz where baz.stringDateMap['now'] is not null" ); 495 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']" ); 496 parse( "select index(date) from org.hibernate.test.Baz baz join baz.stringDateMap date" ); 497 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" ); 498 parse( "from org.hibernate.test.Baz baz inner join baz.collectionComponent.nested.foos foo where foo.string is null" ); 499 parse( "from org.hibernate.test.Baz baz inner join baz.fooSet where '1' in (from baz.fooSet foo where foo.string is not null)" ); 500 parse( "from org.hibernate.test.Baz baz where 'a' in elements(baz.collectionComponent.nested.foos) and 1.0 in elements(baz.collectionComponent.nested.floats)" ); 501 parse( "from org.hibernate.test.Foo foo join foo.foo where foo.foo in ('1','2','3')" ); 502 parse( "select foo.foo from org.hibernate.test.Foo foo where foo.foo in ('1','2','3')" ); 503 parse( "select foo.foo.string from org.hibernate.test.Foo foo where foo.foo in ('1','2','3')" ); 504 parse( "select foo.foo.string from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3')" ); 505 parse( "select foo.foo.long from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3')" ); 506 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)" ); 507 parse( "select count(*) from org.hibernate.test.Foo foo where foo.foo.string in ('1','2','3') group by foo.foo.long" ); 508 parse( "from org.hibernate.test.Foo foo1 left join foo1.foo foo2 left join foo2.foo where foo1.string is not null" ); 509 parse( "from org.hibernate.test.Foo foo1 left join foo1.foo.foo where foo1.string is not null" ); 510 parse( "from org.hibernate.test.Foo foo1 left join foo1.foo foo2 left join foo1.foo.foo foo3 where foo1.string is not null" ); 511 parse( "select foo.formula from org.hibernate.test.Foo foo where foo.formula > 0" ); 512 parse( "from org.hibernate.test.Foo as foo join foo.foo as foo2 where foo2.id >'a' or foo2.id <'a'" ); 513 parse( "from org.hibernate.test.Holder" ); 514 parse( "from org.hibernate.test.Baz baz left outer join fetch baz.manyToAny" ); 515 parse( "from org.hibernate.test.Baz baz join baz.manyToAny" ); 516 parse( "select baz from org.hibernate.test.Baz baz join baz.manyToAny a where index(a) = 0" ); 517 parse( "select bar from org.hibernate.test.Bar bar where bar.baz.stringDateMap['now'] is not null" ); 518 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" ); 519 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" ); 520 parse( "select foo.string, foo.component, foo.id from org.hibernate.test.Bar foo" ); 521 parse( "select elements(baz.components) from org.hibernate.test.Baz baz" ); 522 parse( "select bc.name from org.hibernate.test.Baz baz join baz.components bc" ); 523 parse( "from org.hibernate.test.Foo foo where foo.integer < 10 order by foo.string" ); 524 parse( "from org.hibernate.test.Fee" ); 525 parse( "from org.hibernate.test.Holder h join h.otherHolder oh where h.otherHolder.name = 'bar'" ); 526 parse( "from org.hibernate.test.Baz baz join baz.fooSet foo join foo.foo.foo foo2 where foo2.string = 'foo'" ); 527 parse( "from org.hibernate.test.Baz baz join baz.fooArray foo join foo.foo.foo foo2 where foo2.string = 'foo'" ); 528 parse( "from org.hibernate.test.Baz baz join baz.stringDateMap date where index(date) = 'foo'" ); 529 parse( "from org.hibernate.test.Baz baz join baz.topGlarchez g where index(g) = 'A'" ); 530 parse( "select index(g) from org.hibernate.test.Baz baz join baz.topGlarchez g" ); 531 parse( "from org.hibernate.test.Baz baz left join baz.stringSet" ); 532 parse( "from org.hibernate.test.Baz baz join baz.stringSet str where str='foo'" ); 533 parse( "from org.hibernate.test.Baz baz left join fetch baz.stringSet" ); 534 parse( "from org.hibernate.test.Baz baz join baz.stringSet string where string='foo'" ); 535 parse( "from org.hibernate.test.Baz baz inner join baz.components comp where comp.name='foo'" ); 536 parse( "from org.hibernate.test.Glarch g inner join g.fooComponents comp where comp.fee is not null" ); 537 parse( "from org.hibernate.test.Glarch g inner join g.fooComponents comp join comp.fee fee where fee.count > 0" ); 538 parse( "from org.hibernate.test.Glarch g inner join g.fooComponents comp where comp.fee.count is not null" ); 539 parse( "from org.hibernate.test.Baz baz left join fetch baz.fooBag" ); 540 parse( "from org.hibernate.test.Glarch" ); 541 parse( "from org.hibernate.test.Fee" ); 542 parse( "from org.hibernate.test.Baz baz left join fetch baz.sortablez order by baz.name asc" ); 543 parse( "from org.hibernate.test.Baz baz order by baz.name asc" ); 544 parse( "from org.hibernate.test.Foo foo, org.hibernate.test.Baz baz left join fetch baz.fees" ); 545 parse( "from org.hibernate.test.Foo foo, org.hibernate.test.Bar bar" ); 546 parse( "from org.hibernate.test.Foo foo" ); 547 parse( "from org.hibernate.test.Foo foo, org.hibernate.test.Bar bar, org.hibernate.test.Bar bar2" ); 548 parse( "from org.hibernate.test.X x" ); 549 parse( "from org.hibernate.test.Foo foo" ); 550 parse( "select distinct foo from org.hibernate.test.Foo foo" ); 551 parse( "from org.hibernate.test.Glarch g where g.multiple.glarch=g and g.multiple.count=12" ); 552 parse( "from org.hibernate.test.Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like 'Bar %'" ); 553 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%'" ); 554 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" ); 555 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%'" ); 556 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" ); 557 parse( "select bar from org.hibernate.test.Bar as bar where bar.x > ? or bar.short = 1 or bar.string = 'ff ? bb'" ); 558 parse( "select bar from org.hibernate.test.Bar as bar where bar.string = ' ? ' or bar.string = '?'" ); 559 parse( "from org.hibernate.test.Baz baz, baz.fooArray foo" ); 560 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 = ?" ); 561 parse( "from s in class org.hibernate.test.Stuff where s.foo.id = ? and s.id.id = ? and s.moreStuff.name = ?" ); 562 parse( "from s in class org.hibernate.test.Stuff where s.foo.string is not null" ); 563 parse( "from s in class org.hibernate.test.Stuff where s.foo > '0' order by s.foo" ); 564 parse( "from ms in class org.hibernate.test.MoreStuff" ); 565 parse( "from foo in class org.hibernate.test.Foo" ); 566 parse( "from fee in class org.hibernate.test.Fee" ); 567 parse( "select new Result(foo.string, foo.long, foo.integer) from foo in class org.hibernate.test.Foo" ); 568 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" ); 569 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" ); 570 parse( "select max( elements(bar.baz.fooArray) ) from org.hibernate.test.Bar as bar" ); 571 parse( "from org.hibernate.test.Baz baz left join baz.fooToGlarch join fetch baz.fooArray foo left join fetch foo.foo" ); 572 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" ); 573 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" ); 574 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" ); 575 parse( "select baz.name from org.hibernate.test.Bar bar, bar.baz baz, baz.fooSet foo where baz.name = bar.string" ); 576 parse( "SELECT baz.name FROM org.hibernate.test.Bar AS bar, bar.baz AS baz, baz.fooSet AS foo WHERE baz.name = bar.string" ); 577 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" ); 578 parse( "select foo.string from org.hibernate.test.Bar bar left join bar.baz.fooSet foo where bar.string = foo.string" ); 579 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" ); 580 parse( "select foo.string from org.hibernate.test.Bar bar left join bar.baz.fooArray foo where bar.string = foo.string" ); 581 parse( "select foo from bar in class org.hibernate.test.Bar inner join bar.baz as baz inner join baz.fooSet as foo" ); 582 parse( "select foo from bar in class org.hibernate.test.Bar inner join bar.baz.fooSet as foo" ); 583 parse( "select foo from bar in class org.hibernate.test.Bar, bar.baz as baz, baz.fooSet as foo" ); 584 parse( "select foo from bar in class org.hibernate.test.Bar, bar.baz.fooSet as foo" ); 585 parse( "from org.hibernate.test.Bar bar join bar.baz.fooArray foo" ); 586 parse( "from bar in class org.hibernate.test.Bar, foo in elements( bar.baz.fooArray )" ); 587 parse( "select one.id, elements(one.manies) from one in class org.hibernate.test.One" ); 588 parse( "select max( elements(one.manies) ) from one in class org.hibernate.test.One" ); 589 parse( "select one, elements(one.manies) from one in class org.hibernate.test.One" ); 590 parse( "select one, max(elements(one.manies)) from one in class org.hibernate.test.One group by one" ); 591 parse( "select elements(baz.fooArray) from baz in class org.hibernate.test.Baz where baz.id=?" ); 592 parse( "select elements(baz.fooArray) from baz in class org.hibernate.test.Baz where baz.id=?" ); 593 parse( "select indices(baz.fooArray) from baz in class org.hibernate.test.Baz where baz.id=?" ); 594 parse( "select baz, max(elements(baz.timeArray)) from baz in class org.hibernate.test.Baz group by baz" ); 595 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" ); 596 parse( "select max( elements(baz.timeArray) ) from baz in class org.hibernate.test.Baz where baz.id=?" ); 597 parse( "select max(elements(baz.stringSet)) from baz in class org.hibernate.test.Baz where baz.id=?" ); 598 parse( "select size(baz.stringSet) from baz in class org.hibernate.test.Baz where baz.id=?" ); 599 parse( "from org.hibernate.test.Foo foo where foo.component.glarch.id is not null" ); 600 parse( "from baz in class org.hibernate.test.Baz" ); 601 parse( "select elements(baz.stringArray) from baz in class org.hibernate.test.Baz" ); 602 parse( "from foo in class org.hibernate.test.Foo" ); 603 parse( "select elements(baz.stringList) from baz in class org.hibernate.test.Baz" ); 604 parse( "select count(*) from org.hibernate.test.Bar" ); 605 parse( "select count(*) from b in class org.hibernate.test.Bar" ); 606 parse( "from g in class org.hibernate.test.Glarch" ); 607 parse( "select baz, baz from baz in class org.hibernate.test.Baz" ); 608 parse( "select baz from baz in class org.hibernate.test.Baz order by baz" ); 609 parse( "from bar in class org.hibernate.test.Bar" ); 610 parse( "from g in class org.hibernate.test.Glarch" ); 611 parse( "from f in class org.hibernate.test.Foo" ); 612 parse( "from o in class org.hibernate.test.One" ); 613 parse( "from q in class org.hibernate.test.Qux" ); 614 parse( "select foo from foo in class org.hibernate.test.Foo where foo.string='foo bar'" ); 615 parse( "from foo in class org.hibernate.test.Foo order by foo.string, foo.date" ); 616 parse( "from foo in class org.hibernate.test.Foo where foo.class='B'" ); 617 parse( "from foo in class org.hibernate.test.Foo where foo.class=Bar" ); 618 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" ); 619 parse( "from foo in class org.hibernate.test.Foo where foo.string='foo bar'" ); 620 parse( "select foo from foo in class org.hibernate.test.Foo" ); 621 parse( "from bar in class org.hibernate.test.Bar where bar.barString='bar bar'" ); 622 parse( "from t in class org.hibernate.test.Trivial" ); 623 parse( "from foo in class org.hibernate.test.Foo where foo.date = ?" ); 624 parse( "from o in class org.hibernate.test.MoreStuff" ); 625 parse( "from o in class org.hibernate.test.Many" ); 626 parse( "from o in class org.hibernate.test.Fee" ); 627 parse( "from o in class org.hibernate.test.Qux" ); 628 parse( "from o in class org.hibernate.test.Y" ); 629 parse( "from o in class org.hibernate.test.Fumm" ); 630 parse( "from o in class org.hibernate.test.X" ); 631 parse( "from o in class org.hibernate.test.Simple" ); 632 parse( "from o in class org.hibernate.test.Location" ); 633 parse( "from o in class org.hibernate.test.Holder" ); 634 parse( "from o in class org.hibernate.test.Part" ); 635 parse( "from o in class org.hibernate.test.Baz" ); 636 parse( "from o in class org.hibernate.test.Vetoer" ); 637 parse( "from o in class org.hibernate.test.Sortable" ); 638 parse( "from o in class org.hibernate.test.Contained" ); 639 parse( "from o in class org.hibernate.test.Stuff" ); 640 parse( "from o in class org.hibernate.test.Immutable" ); 641 parse( "from o in class org.hibernate.test.Container" ); 642 parse( "from o in class org.hibernate.test.X$XX" ); 643 parse( "from o in class org.hibernate.test.One" ); 644 parse( "from o in class org.hibernate.test.Foo" ); 645 parse( "from o in class org.hibernate.test.Fo" ); 646 parse( "from o in class org.hibernate.test.Glarch" ); 647 parse( "from o in class org.hibernate.test.Fum" ); 648 parse( "from q in class org.hibernate.test.Qux where q.stuff is null" ); 649 parse( "from q in class org.hibernate.test.Qux where q.stuff=?" ); 650 parse( "from q in class org.hibernate.test.Qux" ); 651 parse( "from g in class org.hibernate.test.Glarch where g.version=2" ); 652 parse( "from g in class org.hibernate.test.Glarch where g.next is not null" ); 653 parse( "from g in class org.hibernate.test.Glarch order by g.order asc" ); 654 parse( "from foo in class org.hibernate.test.Foo order by foo.string asc" ); 655 parse( "select parent, child from parent in class org.hibernate.test.Foo, child in class org.hibernate.test.Foo where parent.foo = child" ); 656 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" ); 657 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" ); 658 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" ); 659 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'" ); 660 parse( "from fee in class org.hibernate.test.Fee" ); 661 parse( "from org.hibernate.test.Foo foo where foo.custom.s1 = 'one'" ); 662 parse( "from im in class org.hibernate.test.Immutable where im = ?" ); 663 parse( "from foo in class org.hibernate.test.Foo" ); 664 parse( "from foo in class org.hibernate.test.Foo where foo.char='X'" ); 665 parse( "select elements(baz.stringArray) from baz in class org.hibernate.test.Baz" ); 666 parse( "select distinct elements(baz.stringArray) from baz in class org.hibernate.test.Baz" ); 667 parse( "select elements(baz.fooArray) from baz in class org.hibernate.test.Baz" ); 668 parse( "from foo in class org.hibernate.test.Fo" ); 669 parse( "from foo in class org.hibernate.test.Foo where foo.dependent.qux.foo.string = 'foo2'" ); 670 parse( "from org.hibernate.test.Bar bar where bar.object.id = ? and bar.object.class = ?" ); 671 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'" ); 672 parse( "from l in class org.hibernate.test.Location where l.countryCode = 'AU' and l.description='foo bar'" ); 673 parse( "from org.hibernate.test.Bar bar" ); 674 parse( "From org.hibernate.test.Bar bar" ); 675 parse( "From org.hibernate.test.Foo foo" ); 676 parse( "from o in class org.hibernate.test.Baz" ); 677 parse( "from o in class org.hibernate.test.Foo" ); 678 parse( "from f in class org.hibernate.test.Foo" ); 679 parse( "select fum.id from fum in class org.hibernate.test.Fum where not fum.fum='FRIEND'" ); 680 parse( "select fum.id from fum in class org.hibernate.test.Fum where not fum.fum='FRIEND'" ); 681 parse( "from fum in class org.hibernate.test.Fum where not fum.fum='FRIEND'" ); 682 parse( "from fo in class org.hibernate.test.Fo where fo.id.string like 'an instance of fo'" ); 683 parse( "from org.hibernate.test.Inner" ); 684 parse( "from org.hibernate.test.Outer o where o.id.detailId = ?" ); 685 parse( "from org.hibernate.test.Outer o where o.id.master.id.sup.dudu is not null" ); 686 parse( "from org.hibernate.test.Outer o where o.id.master.id.sup.id.akey is not null" ); 687 parse( "select o.id.master.id.sup.dudu from org.hibernate.test.Outer o where o.id.master.id.sup.dudu is not null" ); 688 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" ); 689 parse( "from org.hibernate.test.Outer o where o.id.master.bla = ''" ); 690 parse( "from org.hibernate.test.Outer o where o.id.master.id.one = ''" ); 691 parse( "from org.hibernate.test.Inner inn where inn.id.bkey is not null and inn.backOut.id.master.id.sup.id.akey > 'a'" ); 692 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" ); 693 parse( "from org.hibernate.test.Outer as o left join o.id.master.id.sup s where o.bubu is not null" ); 694 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" ); 695 parse( "select fum1.fo from fum1 in class org.hibernate.test.Fum where fum1.fo.fum is not null" ); 696 parse( "from fum1 in class org.hibernate.test.Fum where fum1.fo.fum is not null order by fum1.fo.fum" ); 697 parse( "select elements(fum1.friends) from fum1 in class org.hibernate.test.Fum" ); 698 parse( "from fum1 in class org.hibernate.test.Fum, fr in elements( fum1.friends )" ); 699 parse( "select new Jay(eye) from org.hibernate.test.Eye eye" ); 700 parse( "from org.hibernate.test.Category cat where cat.name='new foo'" ); 701 parse( "from org.hibernate.test.Category cat where cat.name='new sub'" ); 702 parse( "from org.hibernate.test.Up up order by up.id2 asc" ); 703 parse( "from org.hibernate.test.Down down" ); 704 parse( "from org.hibernate.test.Up up" ); 705 parse( "from m in class org.hibernate.test.Master" ); 706 parse( "from s in class org.hibernate.test.Several" ); 707 parse( "from s in class org.hibernate.test.Single" ); 708 parse( "\n" + 709 " from d in class \n" + 710 " org.hibernate.test.Detail\n" + 711 " " ); 712 parse( "from c in class org.hibernate.test.Category where c.name = org.hibernate.test.Category.ROOT_CATEGORY" ); 713 parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where c.oneToMany[2] = s" ); 714 parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where c.manyToMany[2] = s" ); 715 parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where s = c.oneToMany[2]" ); 716 parse( "select c from c in class org.hibernate.test.Container, s in class org.hibernate.test.Simple where s = c.manyToMany[2]" ); 717 parse( "select c from c in class org.hibernate.test.Container where c.oneToMany[0].name = 's'" ); 718 parse( "select c from c in class org.hibernate.test.Container where c.manyToMany[0].name = 's'" ); 719 parse( "select c from c in class org.hibernate.test.Container where 's' = c.oneToMany[2 - 2].name" ); 720 parse( "select c from c in class org.hibernate.test.Container where 's' = c.manyToMany[(3+1)/4-1].name" ); 721 parse( "select c from c in class org.hibernate.test.Container where c.manyToMany[ maxindex(c.manyToMany) ].count = 2" ); 722 parse( "select c from c in class org.hibernate.test.Container where c.oneToMany[ c.manyToMany[0].count ].name = 's'" ); 723 parse( "select c from org.hibernate.test.Container c where c.manyToMany[ c.oneToMany[0].count ].name = 's'" ); 724 parse( "select count(comp.name) from org.hibernate.test.Container c join c.components comp" ); 725 parse( "from org.hibernate.test.Parent p left join fetch p.child" ); 726 parse( "from org.hibernate.test.Parent p join p.child c where c.x > 0" ); 727 parse( "from org.hibernate.test.Child c join c.parent p where p.x > 0" ); 728 parse( "from org.hibernate.test.Child" ); 729 parse( "from org.hibernate.test.MoreStuff" ); 730 parse( "from org.hibernate.test.Many" ); 731 parse( "from org.hibernate.test.Fee" ); 732 parse( "from org.hibernate.test.Qux" ); 733 parse( "from org.hibernate.test.Fumm" ); 734 parse( "from org.hibernate.test.Parent" ); 735 parse( "from org.hibernate.test.Simple" ); 736 parse( "from org.hibernate.test.Holder" ); 737 parse( "from org.hibernate.test.Part" ); 738 parse( "from org.hibernate.test.Baz" ); 739 parse( "from org.hibernate.test.Vetoer" ); 740 parse( "from org.hibernate.test.Sortable" ); 741 parse( "from org.hibernate.test.Contained" ); 742 parse( "from org.hibernate.test.Circular" ); 743 parse( "from org.hibernate.test.Stuff" ); 744 parse( "from org.hibernate.test.Immutable" ); 745 parse( "from org.hibernate.test.Container" ); 746 parse( "from org.hibernate.test.One" ); 747 parse( "from org.hibernate.test.Foo" ); 748 parse( "from org.hibernate.test.Fo" ); 749 parse( "from org.hibernate.test.Glarch" ); 750 parse( "from org.hibernate.test.Fum" ); 751 parse( "from org.hibernate.test.Glarch g" ); 752 parse( "from org.hibernate.test.Part" ); 753 parse( "from org.hibernate.test.Baz baz join baz.parts" ); 754 parse( "from c in class org.hibernate.test.Child where c.parent.count=66" ); 755 parse( "from org.hibernate.test.Parent p join p.child c where p.count=66" ); 756 parse( "select c, c.parent from c in class org.hibernate.test.Child order by c.parent.count" ); 757 parse( "select c, c.parent from c in class org.hibernate.test.Child where c.parent.count=66 order by c.parent.count" ); 758 parse( "select c, c.parent, c.parent.count from c in class org.hibernate.test.Child order by c.parent.count" ); 759 parse( "FROM p IN CLASS org.hibernate.test.Parent WHERE p.count = ?" ); 760 parse( "select count(*) from org.hibernate.test.Container as c join c.components as ce join ce.simple as s where ce.name='foo'" ); 761 parse( "select c, s from org.hibernate.test.Container as c join c.components as ce join ce.simple as s where ce.name='foo'" ); 762 parse( "from s in class org.hibernate.test.Simple" ); 763 parse( "from m in class org.hibernate.test.Many" ); 764 parse( "from o in class org.hibernate.test.One" ); 765 parse( "from c in class org.hibernate.test.Container" ); 766 parse( "from o in class org.hibernate.test.Child" ); 767 parse( "from o in class org.hibernate.test.MoreStuff" ); 768 parse( "from o in class org.hibernate.test.Many" ); 769 parse( "from o in class org.hibernate.test.Fee" ); 770 parse( "from o in class org.hibernate.test.Qux" ); 771 parse( "from o in class org.hibernate.test.Fumm" ); 772 parse( "from o in class org.hibernate.test.Parent" ); 773 parse( "from o in class org.hibernate.test.Simple" ); 774 parse( "from o in class org.hibernate.test.Holder" ); 775 parse( "from o in class org.hibernate.test.Part" ); 776 parse( "from o in class org.hibernate.test.Baz" ); 777 parse( "from o in class org.hibernate.test.Vetoer" ); 778 parse( "from o in class org.hibernate.test.Sortable" ); 779 parse( "from o in class org.hibernate.test.Contained" ); 780 parse( "from o in class org.hibernate.test.Circular" ); 781 parse( "from o in class org.hibernate.test.Stuff" ); 782 parse( "from o in class org.hibernate.test.Immutable" ); 783 parse( "from o in class org.hibernate.test.Container" ); 784 parse( "from o in class org.hibernate.test.One" ); 785 parse( "from o in class org.hibernate.test.Foo" ); 786 parse( "from o in class org.hibernate.test.Fo" ); 787 parse( "from o in class org.hibernate.test.Glarch" ); 788 parse( "from o in class org.hibernate.test.Fum" ); 789 parse( "from c in class org.hibernate.test.C2 where 1=1 or 1=1" ); 790 parse( "from b in class org.hibernate.test.B" ); 791 parse( "from a in class org.hibernate.test.A" ); 792 parse( "from b in class org.hibernate.test.B" ); 793 parse( "from org.hibernate.test.E e join e.reverse as b where b.count=1" ); 794 parse( "from org.hibernate.test.E e join e.as as b where b.count=1" ); 795 parse( "from org.hibernate.test.B" ); 796 parse( "from org.hibernate.test.C1" ); 797 parse( "from org.hibernate.test.C2" ); 798 parse( "from org.hibernate.test.E e, org.hibernate.test.A a where e.reverse = a.forward and a = ?" ); 799 parse( "from org.hibernate.test.E e join fetch e.reverse" ); 800 parse( "from org.hibernate.test.E e" ); 801 parse( "select max(s.count) from s in class org.hibernate.test.Simple" ); 802 parse( "select new org.hibernate.test.S(s.count, s.address) from s in class org.hibernate.test.Simple" ); 803 parse( "select max(s.count) from s in class org.hibernate.test.Simple" ); 804 parse( "select count(*) from s in class org.hibernate.test.Simple" ); 805 parse( "from s in class org.hibernate.test.Simple where s.name=:name and s.count=:count" ); 806 parse( "from s in class org.hibernate.test.Simple where s.name in (:several0_, :several1_)" ); 807 parse( "from s in class org.hibernate.test.Simple where s.name in (:stuff0_, :stuff1_)" ); 808 parse( "from org.hibernate.test.Simple s where s.name=?" ); 809 parse( "from org.hibernate.test.Simple s where s.name=:name" ); 810 parse( "from s in class org.hibernate.test.Simple where upper( s.name ) ='SIMPLE 1'" ); 811 parse( "from s in class org.hibernate.test.Simple where not( upper( s.name ) ='yada' or 1=2 or 'foo'='bar' or not('foo'='foo') or 'foo' like 'bar' )" ); 812 parse( "from s in class org.hibernate.test.Simple where lower( s.name || ' foo' ) ='simple 1 foo'" ); 813 parse( "from s in class org.hibernate.test.Simple where upper( s.other.name ) ='SIMPLE 2'" ); 814 parse( "from s in class org.hibernate.test.Simple where not ( upper( s.other.name ) ='SIMPLE 2' )" ); 815 parse( "select distinct s from s in class org.hibernate.test.Simple where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2" ); 816 parse( "select s from s in class org.hibernate.test.Simple where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2 order by s.other.count" ); 817 parse( "select sum(s.count) from s in class org.hibernate.test.Simple group by s.count having sum(s.count) > 10" ); 818 parse( "select s.count from s in class org.hibernate.test.Simple group by s.count having s.count = 12" ); 819 parse( "select s.id, s.count, count(t), max(t.date) from s in class org.hibernate.test.Simple, t in class org.hibernate.test.Simple where s.count = t.count group by s.id, s.count order by s.count" ); 820 parse( "from s in class org.hibernate.test.Simple" ); 821 parse( "from s in class org.hibernate.test.Simple where s.name = ?" ); 822 parse( "from s in class org.hibernate.test.Simple where s.name = ? and upper(s.name) = ?" ); 823 parse( "from s in class org.hibernate.test.Simple where s.name = :foo and upper(s.name) = :bar or s.count=:count or s.count=:count + 1" ); 824 parse( "select s.id from s in class org.hibernate.test.Simple" ); 825 parse( "select all s, s.other from s in class org.hibernate.test.Simple where s = :s" ); 826 parse( "from s in class org.hibernate.test.Simple where s.name in (:name_list0_, :name_list1_) and s.count > :count" ); 827 parse( "from org.hibernate.test.Simple s" ); 828 parse( "from org.hibernate.test.Simple s" ); 829 parse( "from org.hibernate.test.Assignable" ); 830 parse( "from org.hibernate.test.Category" ); 831 parse( "from org.hibernate.test.Simple" ); 832 parse( "from org.hibernate.test.A" ); 833 parse( "from foo in class org.hibernate.test.Foo where foo.string=?" ); 834 parse( "from foo in class org.hibernate.test.Foo" ); 835 parse( "from org.hibernate.test.Po po, org.hibernate.test.Lower low where low.mypo = po" ); 836 parse( "from org.hibernate.test.Po po join po.set as sm where sm.amount > 0" ); 837 parse( "from org.hibernate.test.Po po join po.top as low where low.foo = 'po'" ); 838 parse( "from org.hibernate.test.SubMulti sm join sm.children smc where smc.name > 'a'" ); 839 parse( "select s, ya from org.hibernate.test.Lower s join s.yetanother ya" ); 840 parse( "from org.hibernate.test.Lower s1 join s1.bag s2" ); 841 parse( "from org.hibernate.test.Lower s1 left join s1.bag s2" ); 842 parse( "select s, a from org.hibernate.test.Lower s join s.another a" ); 843 parse( "select s, a from org.hibernate.test.Lower s left join s.another a" ); 844 parse( "from org.hibernate.test.Top s, org.hibernate.test.Lower ls" ); 845 parse( "from org.hibernate.test.Lower ls join ls.set s where s.name > 'a'" ); 846 parse( "from org.hibernate.test.Po po join po.list sm where sm.name > 'a'" ); 847 parse( "from org.hibernate.test.Lower ls inner join ls.another s where s.name is not null" ); 848 parse( "from org.hibernate.test.Lower ls where ls.other.another.name is not null" ); 849 parse( "from org.hibernate.test.Multi m where m.derived like 'F%'" ); 850 parse( "from org.hibernate.test.SubMulti m where m.derived like 'F%'" ); 851 parse( "select s from org.hibernate.test.SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null" ); 852 parse( "select elements(sm.children) from org.hibernate.test.SubMulti as sm" ); 853 parse( "select distinct sm from org.hibernate.test.SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null" ); 854 parse( "select distinct s from s in class org.hibernate.test.SubMulti where s.moreChildren[1].amount < 1.0" ); 855 parse( "from s in class org.hibernate.test.TrivialClass where s.id = 2" ); 856 parse( "select s.count from s in class org.hibernate.test.Top" ); 857 parse( "from s in class org.hibernate.test.Lower where s.another.name='name'" ); 858 parse( "from s in class org.hibernate.test.Lower where s.yetanother.name='name'" ); 859 parse( "from s in class org.hibernate.test.Lower where s.yetanother.name='name' and s.yetanother.foo is null" ); 860 parse( "from s in class org.hibernate.test.Top where s.count=1" ); 861 parse( "select s.count from s in class org.hibernate.test.Top, ls in class org.hibernate.test.Lower where ls.another=s" ); 862 parse( "select elements(ls.bag), elements(ls.set) from ls in class org.hibernate.test.Lower" ); 863 parse( "from s in class org.hibernate.test.Lower" ); 864 parse( "from s in class org.hibernate.test.Top" ); 865 parse( "from sm in class org.hibernate.test.SubMulti" ); 866 parse( "select\n" + 867 "\n" + 868 "s from s in class org.hibernate.test.Top where s.count>0" ); 869 parse( "from m in class org.hibernate.test.Multi where m.count>0 and m.extraProp is not null" ); 870 parse( "from m in class org.hibernate.test.Top where m.count>0 and m.name is not null" ); 871 parse( "from m in class org.hibernate.test.Lower where m.other is not null" ); 872 parse( "from m in class org.hibernate.test.Multi where m.other.id = 1" ); 873 parse( "from m in class org.hibernate.test.SubMulti where m.amount > 0.0" ); 874 parse( "from m in class org.hibernate.test.Multi" ); 875 parse( "from m in class org.hibernate.test.Multi where m.class = SubMulti" ); 876 parse( "from m in class org.hibernate.test.Top where m.class = Multi" ); 877 parse( "from s in class org.hibernate.test.Top" ); 878 parse( "from ls in class org.hibernate.test.Lower" ); 879 parse( "from ls in class org.hibernate.test.Lower, s in elements(ls.bag) where s.id is not null" ); 880 parse( "from ls in class org.hibernate.test.Lower, s in elements(ls.set) where s.id is not null" ); 881 parse( "from o in class org.hibernate.test.Top" ); 882 parse( "from o in class org.hibernate.test.Po" ); 883 parse( "from ChildMap cm where cm.parent is not null" ); 884 parse( "from ParentMap cm where cm.child is not null" ); 885 parse( "from org.hibernate.test.Componentizable" ); 886 } 887 888 public void testUnnamedParameter() throws Exception { 889 parse( "select foo, bar from org.hibernate.test.Foo foo left outer join foo.foo bar where foo = ?" ); } 891 892 public void testInElements() throws Exception { 893 parse( "from bar in class org.hibernate.test.Bar, foo in elements(bar.baz.fooArray)" ); } 895 896 public void testDotElements() throws Exception { 897 parse( "select distinct foo from baz in class org.hibernate.test.Baz, foo in elements(baz.fooArray)" ); 898 parse( "select foo from baz in class org.hibernate.test.Baz, foo in elements(baz.fooSet)" ); 899 parse( "select foo from baz in class org.hibernate.test.Baz, foo in elements(baz.fooArray)" ); 900 parse( "from org.hibernate.test.Baz baz where 'b' in elements(baz.collectionComponent.nested.foos) and 1.0 in elements(baz.collectionComponent.nested.floats)" ); 901 } 902 903 public void testSelectAll() throws Exception { 904 parse( "select all s, s.other from s in class org.hibernate.test.Simple where s = :s" ); 905 } 906 907 public void testNot() throws Exception { 908 parse( "from eg.Cat cat where not ( cat.kittens.size < 1 )" ); 910 parse( "from eg.Cat cat where not ( cat.kittens.size > 1 )" ); 911 parse( "from eg.Cat cat where not ( cat.kittens.size >= 1 )" ); 912 parse( "from eg.Cat cat where not ( cat.kittens.size <= 1 )" ); 913 parse( "from eg.DomesticCat cat where not ( cat.name between 'A' and 'B' ) " ); 914 parse( "from eg.DomesticCat cat where not ( cat.name not between 'A' and 'B' ) " ); 915 parse( "from eg.Cat cat where not ( not cat.kittens.size <= 1 )" ); 916 parse( "from eg.Cat cat where not not ( not cat.kittens.size <= 1 )" ); 917 } 918 919 public void testOtherSyntax() throws Exception { 920 parse( "select bar from org.hibernate.test.Bar bar order by ((bar.x - :valueX)*(bar.x - :valueX))" ); 921 parse( "from bar in class org.hibernate.test.Bar, foo in elements(bar.baz.fooSet)" ); 922 parse( "from one in class org.hibernate.test.One, many in elements(one.manies) where one.id = 1 and many.id = 1" ); 923 parse( "from org.hibernate.test.Inner _inner join _inner.middles middle" ); 924 parse( "FROM m IN CLASS org.hibernate.test.Master WHERE NOT EXISTS ( FROM d IN elements(m.details) WHERE NOT d.i=5 )" ); 925 parse( "FROM m IN CLASS org.hibernate.test.Master WHERE NOT 5 IN ( SELECT d.i FROM d IN elements(m.details) )" ); 926 parse( "SELECT m FROM m IN CLASS org.hibernate.test.Master, d IN elements(m.details) WHERE d.i=5" ); 927 parse( "SELECT m FROM m IN CLASS org.hibernate.test.Master, d IN elements(m.details) WHERE d.i=5" ); 928 parse( "SELECT m.id FROM m IN CLASS org.hibernate.test.Master, d IN elements(m.details) WHERE d.i=5" ); 929 } 935 936 public void testEjbqlExtensions() throws Exception { 937 parse( "select object(a) from Animal a where a.mother member of a.offspring" ); 938 parse( "select object(a) from Animal a where a.offspring is empty" ); 939 } 940 941 public void testEmptyFilter() throws Exception { 942 parseFilter( "" ); } 944 945 public void testOrderByFilter() throws Exception { 946 parseFilter( "order by this.id" ); 947 } 948 949 public void testRestrictionFilter() throws Exception { 950 parseFilter( "where this.name = ?" ); 951 } 952 953 public void testNoFrom() throws Exception { 954 System.out.println( "***** This test ensures that an error is detected ERROR MESSAGES ARE OKAY! *****" ); 955 HqlParser parser = HqlParser.getInstance( "" ); 956 parser.setFilter( false ); 957 parser.statement(); 958 assertEquals( "Parser allowed no FROM clause!", 1, parser.getParseErrorHandler().getErrorCount() ); 959 System.out.println( "***** END OF ERROR TEST *****" ); 960 } 961 962 public void testHB1042() throws Exception { 963 parse( "select x from fmc_web.pool.Pool x left join x.containers c0 where (upper(x.name) = upper(':') and c0.id = 1)" ); 964 } 965 966 public void testKeywordInPath() throws Exception { 967 parse( "from Customer c where c.order.status = 'argh'" ); 969 parse( "from Customer c where c.order.count > 3" ); 971 parse( "select c.where from Customer c where c.order.count > 3" ); 973 parse( "from Interval i where i.end <:end" ); 974 parse( "from Letter l where l.case = :case" ); 975 } 976 977 public void testPathologicalKeywordAsIdentifier() throws Exception { 978 parse( "from Order order" ); 980 parse( "from X x order by x.group.by.from" ); 982 parse( "from Order x order by x.order.group.by.from" ); 983 parse( "select order.id from Order order" ); 984 parse( "select order from Order order" ); 985 parse( "from Order order where order.group.by.from is not null" ); 986 parse( "from Order order order by order.group.by.from" ); 987 parse( "from Group as group group by group.by.from" ); 989 } 990 991 public void testHHH354() throws Exception { 992 parse( "from Foo f where f.full = 'yep'"); 993 } 994 995 public void testWhereAsIdentifier() throws Exception { 996 parse( "from where.Order" ); 998 } 999 1000 public void testEjbqlKeywordsAsIdentifier() throws Exception { 1001 parse( "from org.hibernate.test.Bar bar where bar.object.id = ? and bar.object.class = ?" ); 1002 } 1003 1004 public void testConstructorIn() throws Exception { 1005 parse( "from org.hibernate.test.Bar bar where (b.x, b.y, b.z) in (select foo, bar, baz from org.hibernate.test.Foo)" ); 1006 } 1007 1008 public void testMultiByteCharacters() throws Exception { 1009 parse ("from User user where user.name like '%nn\u4e2dnn%'"); 1010 parse ("from User user where user.\u432d like '%\u4e2d%'"); 1012 parse ("from \u432d \u432d where \u432d.name like '%fred%'"); 1013 } 1014 1015 public void testHHH719() throws Exception { 1016 parse("from Foo f order by com.fooco.SpecialFunction(f.id)"); 1018 } 1019 1020 private void parseFilter(String input) throws TokenStreamException, RecognitionException { 1021 doParse( input, true ); 1022 } 1023 1024 private void parse(String input) throws RecognitionException, TokenStreamException { 1025 doParse( input, false ); 1026 } 1027 1028 private void doParse(String input, boolean filter) throws RecognitionException, TokenStreamException { 1029 System.out.println( "input: ->" + ASTPrinter.escapeMultibyteChars(input) + "<-" ); 1030 HqlParser parser = HqlParser.getInstance( input ); 1031 parser.setFilter( filter ); 1032 parser.statement(); 1033 AST ast = parser.getAST(); 1034 System.out.println( "AST : " + ast.toStringTree() + "" ); 1035 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 1036 parser.showAst( ast, new PrintStream ( baos ) ); 1037 System.out.println( baos.toString() ); 1038 assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() ); 1039 } 1040 1041 public static Test suite() { 1042 return new TestSuite( HqlParserTest.class ); 1043 } 1044} 1045 | Popular Tags |