Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Search Query Error
Search Query Error [message #898527] Thu, 26 July 2012 14:16 Go to next message
Shanaka Madusanka is currently offline Shanaka Madusanka
Messages: 2
Registered: July 2012
Junior Member
How can i create a (search & like) using "Eclipse Link- 2.4.0"
Is there any option to solve this, If not this may be a bub of "Eclipse Persistence Services - 2.4.0".

Used
try {
  Query q = em.createQuery("SELECT t FROM Teacher AS t WHERE t.name like:name");
    q.setParameter("name", "Am%");
    System.out.println("Size:"+q.getResultList().size());
  } catch (Exception e) {
    e.printStackTrace();
  }


java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [SELECT t FROM Teacher AS t WHERE t.name like:name]. 
[33, 49] The expression is not a valid conditional expression.
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1512)
	at test.Test.main(Test.java:38)
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [SELECT t FROM Teacher AS t WHERE t.name like:name]. 
[33, 49] The expression is not a valid conditional expression.
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:150)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:325)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:270)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:157)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:138)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:112)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:98)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:82)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1510)
	... 1 more


IS THERE ANY OPTION PLEASE

Note: When i use "Eclipse Link- 2.3.2" It works perfectly

[Updated on: Thu, 26 July 2012 14:23]

Report message to a moderator

Re: Search Query Error [message #898792 is a reply to message #898527] Fri, 27 July 2012 15:19 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1026
Registered: July 2009
Senior Member
The query should have a apace between the parameter and the "Like" operator. The parser has changed since 2.3.2, but the old parser is still available using persistence unit property
eclipselink.jpql.parser with a value of org.eclipse.persistence.queries.ANTLRQueryBuilder if you wish to use it instead.

Best Regards,
Chris
Re: Search Query Error [message #898944 is a reply to message #898792] Sun, 29 July 2012 06:12 Go to previous message
Shanaka Madusanka is currently offline Shanaka Madusanka
Messages: 2
Registered: July 2012
Junior Member
Ohh.. THANX CHRIS..
Previous Topic:MOXy + Tomcat6 + Maven
Next Topic:[SOLVED] Entity Class identity problem in OSGi after uninstalling/reinstalling persistence bundle
Goto Forum:
  


Current Time: Thu Oct 02 10:28:12 GMT 2014

Powered by FUDForum. Page generated in 0.20069 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software