File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPQL Query Problem.. - Please help :(" Watch "JPQL Query Problem.. - Please help :(" New topic

JPQL Query Problem.. - Please help :(

Jean Nepton

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( AS id FROM Event e GROUP BY e.description) AS tmpTable ON e.description = tmpTable.description AND ( =;

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

I agree. Here's the link:
subject: JPQL Query Problem.. - Please help :(
It's not a secret anymore!