-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hlq and my sql regexp
PostPosted: Thu Jan 08, 2004 9:42 pm 
Newbie

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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 9:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Try patching net.sf.hibernate.hql.WhereParser


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.