Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Object Relational Mapping and the fly likes JPQL Query Problem.. - Please help :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPQL Query Problem.. - Please help :(" Watch "JPQL Query Problem.. - Please help :(" New topic
Author

JPQL Query Problem.. - Please help :(

Jean Nepton
Greenhorn

Joined: Jun 19, 2013
Posts: 3
I have been trying to create a query for three days now and can't seem to get it to work correctly. Would really appreciate some guidance... Here's my problem

-I have a function that returns a list of <Event> objects from the query (Event is a class that I created to hold events that occur due to a Problem [another Class I created])
-I want to return the all Events that are associated with a Probelm ID
-I do not want to return Events with identical descriptions (because they are the same event) but instead only the one that occured last (Event Max(e.creationDate))
-I would like to Order By creationDate

I am gues my query may need an INNER JOIN, I also tried the DISTINCT keyword.. Here is the script I feel is the closet to what I want..

SELECT * FROM Event e INNER JOIN FETCH (SELECT DISTINCT e.description, MIN(e.id) AS id FROM Event e GROUP BY e.description) AS tmpTable ON e.description = tmpTable.description AND (e.id = tmpTable.id);

I would super appreciate any help.. THANK YOU in advance..

 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: JPQL Query Problem.. - Please help :(