• 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
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

JPQL union

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all
I am trying to map below mention query in JAP.



I have two seperate java classes viz one for master and other for history table. Though I am not getting how exactly should I write the JPQL query or rather which API I am suppose to use to grab the data from the query mentioned above.
Any link, white paper will greatly be appricaited.
Thanks
Samir
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This depend on how you have mapped the tables?

In general in JPA you can use SQL in native queries, so you can use the SQL if you wish.
You could also execute two queries.

JPQL does not support unions, but some JPA providers do,

EclipseLink supports unions in JPQL see,

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#UNION

EclipseLink also has history support which may interest you,

http://wiki.eclipse.org/EclipseLink/Examples/JPA/History
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello James
Thank you so much for the reply.
I have two tables , one is for maintaining document information and other one is for maintaining operations on the documents. (e.g. update,delete) . Both are jsut replica of each other where one is maintaining others audit information.

Both the tables are mapped to two different objects.
I was trying to execute below mention code though I am getting "column not found" exception.
Can you please tell me where exactly I am missing ??
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure what exctly is EclipseLink .. Though I am not using it . I am with bare JPA's API. . So eclipseLink is something on which I cant relay
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not done any explicit mapping except mapping columns to the specific fields as below.



Do I need to do any explicit mapping if I am triggering union query.
I can execute other simple queries but not the one which has union in it
Thanks
Samir
 
Paper beats rock. Scissors beats tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic