Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPQL union

 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • 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
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic