[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Need help on converting SQL to EJB QL
scout1lacno
do-not-reply at jboss.com
Wed Jan 3 19:25:14 EST 2007
Hi all,
Im having problems with my EJB QL statements. Im using MySQL as my database..
The SQL statement below works perfectly on MySQL:
| select o.dateArrived, o.custName , o.IDCategory
| from tblMessages AS o WHERE o.IDCategory = "+categoryId+" and DATE_SUB( '"+dateReceived+"' , INTERVAL 2 DAY ) <= o.datArrived ORDER BY o.datArrived DESC
When transfered the statements to my facade:
| public List getData(String categoryId, String dateReceived){
|
| return em.createQuery
| ("select o.dateArrived, o.custName , o.IDCategory"+
| "from TblMessages AS o WHERE o.IDCategory = "+categoryId+" and "+
| "and DATE_SUB( '"+dateReceived+"' , INTERVAL 2 DAY ) <= o.dateArrived,
| ORDER BY o.datReceived DESC").getResultList();
|
| }
It produce an exception: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 2
Any suggestions?
Thanks. :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997761#3997761
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997761
More information about the jboss-user
mailing list