• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Path expression that evaluates to a collection

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Persistence spec 4.4.5 says that
"It is syntactically illegal to compose a path expression from a path expression that evaluates to a collection.
For example, if o designates Order, the path expression o.lineItems.product is illegal
since navigation to lineItems results in a collection. This case should produce an error when the
query string is verified."

but following query executes without exceptions on sun app server:




and spec's article on the 'group by' doesn't mention any peculiarities for path expressions used in group by clause...

So, where is the bug, in spec, in sun's implementation or i'm missing something?

wbr, eugen.
 
Yevgen Bushuyev
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and



works fine...
 
Saloon Keeper
Posts: 3950
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably it's vendor (Sun) specific feature.

I would trust EJB specification.
 
Yevgen Bushuyev
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The specs says "This case shouldproduce an error when the
query string is verified", so that could not be a feature of a provider, only direct violation of a spec... But i'm using a sun's server bundled with ee5, which is what is called 'reference implementation' i think...
 
Mikalai Zaikin
Saloon Keeper
Posts: 3950
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy !

What is the query result ?

All products from every line item from every order ?

thanks,
MZ
 
Yevgen Bushuyev
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
having

then


returns 9, 9.

Tried to change it to

and got


Internal Exception: java.sql.SQLException: ORA-00979: not a GROUP BY expression
Error Code: 979
Call:SELECT t0.ID, COUNT(*) FROM LINEITEM t4, PRODUCT t3, ORDERR t2, LINEITEM t1
, PRODUCT t0 WHERE ((((t1.ORDER_ID = t2.ID) AND (t0.ID (+) = t1.PRODUCT_ID)) AND
(t4.ORDER_ID = t2.ID)) AND (t3.ID = t4.PRODUCT_ID)) GROUP BY t3.ID
Query:ReportQuery(test.entities.example.Order)
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(D
atabaseException.java:303)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.ba
sicExecuteCall(DatabaseAccessor.java:551)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.ex


.

But


still works ok

wbr, eugen.
[ December 22, 2006: Message edited by: Yevgen Bushuyev ]
 
Yevgen Bushuyev
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the thing with group by should be like this:



which is actually works.

wbr, eugen.
 
Mikalai Zaikin
Saloon Keeper
Posts: 3950
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I asked about query result, I meant:



Just curious, is it runnig Ok too ? For me it's obvious invalid.

Regarding 'GROUP BY' - I am not sure it's on the test - not mentioned in objectives. (I may be wrong).

Thanks,
MZ
 
Yevgen Bushuyev
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, it runs ok and returns the same product as passed to the parameter.

wbr, eugen.
 
Mikalai Zaikin
Saloon Keeper
Posts: 3950
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

Just a hint ...

Try to pass in not a product object reference, rather than some primitive, or simple string.

It must throw an exception at runtime, and in the stack trace you will be able to examine the actual SQL it uses for this Query.

Thanks,
MZ
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic