This content has been marked as final.
Show 2 replies
-
1. Re: EJB QL How to find most recent date??
maximwirt Jan 26, 2006 4:58 AM (in response to fabriciobraga)"fabriciobraga" wrote:
Hi all,
I have a trouble here while trying to find most recent date register from my table.
Here goes my finder method:
public Project findLastCreated() throws RemoteException{
String ejbQl = "select max(p.creationDate) from Project p";
Project result = entityManager.createQuery(ejbQl).getSingleResult();
return result;
}
When running this method it gives me an exception because something about timestamp.
The database is MySql and the field "CREATION_DATE" is "DATETIME" type. Anyone can help me? How can I find the most recent date register using EJB QL?
Regards,
Fabricio Braga
replace
Project result = entityManager.createQuery(ejbQl).getSingleResult();
witn
Date date = (Date)entityManager.createQuery(ejbQl).getSingleResult(); -
2. Re: EJB QL How to find most recent date??
fabriciobraga Jan 27, 2006 7:58 AM (in response to fabriciobraga)
maximwirt,
I've follow your suggestion and now it works fine. Thanks a lot.
Regards,
Fabricio Braga