| Joined: Thu Jan 08, 2004 8:57 pm
 Posts: 6
 | 
				
					| Hi,
 I am new to hibernate and currently using Mysql as my database. I want to write a hlq to search product by keywords using mysql regexp and the queryString i have is
 
 FROM Product as product where p.description REGEXP '[[:<:]]keyword1[[:>:]] and product.description REGEXP '[[:<:]]keyword2[[:>:]]  ...
 
 (Similar SQL statement works fine in plain JDBC)
 
 And I got the following exception from hibernate:
 ======================================
 net.sf.hibernate.QueryException: Incorrect query syntax [FROM au.com.webfox.pinkfairy.entity.hibernate.Product as product WHERE product.description REGEXP '[[:<:]]keyword1[[:>:]]' and product.description REGEXP '[[:<:]]keyword2[[:>:]]' ]
 at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:163)
 at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:133)
 at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:352)
 at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:330)
 at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1368)
 at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1332)
 at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76)
 at org.springframework.orm.hibernate.HibernateTemplate$8.doInHibernate(HibernateTemplate.java:324)
 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147)
 at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:306)
 at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:321)
 at au.com.webfox.pinkfairy.persistence.dao.ProductDao.retrieveProductsByKeyword(ProductDao.java:87)
 at au.com.webfox.pinkfairy.persistence.service.ProductServiceImpl.retrieveProductsByKeyword(ProductServiceImpl.java:271)
 at au.com.webfox.pinkfairy.persistence.service.ProductServiceImpl.retrieveProductsByKeyword(ProductServiceImpl.java:266)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.aop.interceptor.AbstractReflectionInvokerInterceptor.invoke(AbstractReflectionInvokerInterceptor.java:57)
 at org.springframework.aop.framework.MethodInvocationImpl.proceed(MethodInvocationImpl.java:216)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:145)
 at org.springframework.aop.framework.MethodInvocationImpl.proceed(MethodInvocationImpl.java:216)
 at org.springframework.aop.framework.AopProxy.invoke(AopProxy.java:137)
 at $Proxy0.retrieveProductsByKeyword(Unknown Source)
 at au.com.webfox.pinkfairy.hibernate.test.HibernateTest.testProduct(HibernateTest.java:41)
 at au.com.webfox.pinkfairy.hibernate.test.HibernateTest.main(HibernateTest.java:33)
 Caused by: java.util.NoSuchElementException
 at java.util.LinkedList.getLast(Unknown Source)
 at net.sf.hibernate.hql.WhereParser.closeExpression(WhereParser.java:323)
 at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:259)
 at net.sf.hibernate.hql.WhereParser.end(WhereParser.java:305)
 at net.sf.hibernate.hql.ClauseParser.endChild(ClauseParser.java:100)
 at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:108)
 at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:140)
 at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
 at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:146)
 ... 25 more
 Exception in thread "main"
 
 =======================================
 
 Can anyone help me out?
 
 Thanks in advance.
 
 
 |  |