This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 1
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..

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPQL Query Problem.. - Please help :(
 
Similar Threads
many-to-one mapping issue EJB
unable to get names for unique id
Joined Strategy Inheritance problem
SQL Server Exception
JPA - getSingleResult Error