-->
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.  [ 13 posts ] 
Author Message
 Post subject: Creating Regular Expressions in HQL
PostPosted: Mon Apr 24, 2006 1:14 pm 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
Hi,

Im running Hibernate 3.0 and i was wondering if anyone knew how to create regular expressions in HQL. Currently im running on mysql and in which case the SQL statement would be as follows
Code:
select count(*)
From Customer
where customer_last_name REGEXP '^[0-9]'


This works fine and retrieves the correct answer. In HQL i would of thought it would of been something like this

Code:
select count(*)
from Customer as c
where c.customerLastName regexp '^[0-9]'


But this didn't work. Any ideas?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 1:19 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
I do not think this is possible in HQL. You may have to use createSQLQuery to run these types of queries.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 1:37 pm 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
That is a solution that I was thinking about but then I will run into more problems as I want this app to run over multiple DB's including oracle, DB2, PostgreSQL and so on.
Is createSQLQuery() equipped for this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 2:09 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
You should be able to do this by adding a regexp function to each dialect that generates the SQL that you want to use.

For example, with MySQL:-

Code:
public class ExtendedMySQLDialect extends MySQLDialect {
   public ExtendedMySQLDialect () {
      registerFunction( "regexp", new SQLFunctionTemplate(Hibernate.BOOLEAN, "?1 REGEXP ?2") );
   }
}


You may need to play with the return type - not sure what you'd have to use for a where clause but hopefully then you could use it like this in HQL:-

Code:
select count(*)
from Customer as c
where regexp(c.customerLastName, '^[0-9]')


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 2:47 pm 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
Hey r1ch,

I really like that idea! Is this a class that should just be called on startup of the app server?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 9:58 am 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
Heya,

I treid running that class but i get the following error when i try to implement the query.

Code:
14:49:27,902 ERROR [PARSER] line 1:248: unexpected token: regexp
14:49:27,981 ERROR [[action]] Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V
   at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3533)
   at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200)
   at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3082)
   at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2802)
   at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:570)
   at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2586)
   at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2449)
   at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2413)
   at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2341)
   at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2296)
   at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:2082)
   at org.hibernate.hql.antlr.HqlBaseParser.logicalExpression(HqlBaseParser.java:1858)
   at org.hibernate.hql.antlr.HqlBaseParser.whereClause(HqlBaseParser.java:454)
   at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:708)
   at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296)
   at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159)
   at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
   at beans.customer.CustomerDAO.getCustomersByAlpha(CustomerDAO.java:2303)
   at  .actions.SentenialAction.getCustomers(SentenialAction.java:366)
   at  .actions.CustomerAction.getAlphaCustomers(CustomerAction.java:235)
   at  .actions.CustomerAction.executeAction(CustomerAction.java:165)
   at  .actions.SentenialAction.execute(SentenialAction.java:74)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Thread.java:595)

The funny thing is though, there is no error thrown implementing that class. It registers the functions correctly. I spent some time now looking around for an answer to why it won’t pick it up. If you see something that I don’t, let me know.

There error is thrown when i try to create the query, see code below
Code:
buffer.append(from Customer as c where c.customerName regexp '^[0-9]');
Query query = HibernateUtil.getSession().createQuery(buf.toString()); //ERROR THROWN HERE


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 11:27 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Your HQL will have to call the function like this:

Code:
buffer.append("from Customer as c where regexp(c.customerName, '^[0-9]')");


Also, you might find that the HQL mis-interprets the regex operations due to the fact that there is no way to escape them in HQL, so it might be better to pass in the regex as a param, eg:-

Code:
buffer.append("from Customer as c where regexp(c.customerName, ?)");
Query query = HibernateUtil.getSession().createQuery(buf.toString());
query.setString(0, "^[0-9]");


Hope that helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 1:10 pm 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
Hey,

Thanks for that. I gave that a whirl but it came up with the following errors

Code:
07:41,405 INFO  [Dialect] Using dialect: transactionhandler.hibernate.userTypes.ExtendedMySQLDialect
18:07:41,421 ERROR [PARSER] <AST>: unexpected AST node: (


I looked the error up on google but I just got back details about parsing... I tried it a few ways but it still came up with the error above.

Any other ideas???

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 1:45 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
What's the full stack trace for that error?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 7:13 am 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
Hey r1ch,

This is the stack trace for the error

Code:
2006-04-25 18:07:41,452 ERROR .customer.CustomerDAO.getCustomersByAlpha            - getCustomersByAlpha - caught
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ([from beans.directdebitreference.DirectDebitReference as ddr where ddr.client.clientId = :clientId and ddr.directDebitReferenceStatus = :status and ddr.customer.businessCustomer = :businessStatus and regexp(ddr.customer.businessName, '^[0-9]') group by ddr.customer.customerId order by  ddr.customer.businessName]
        at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:225)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
        at  .business.beans.customer.CustomerDAO.getCustomersByAlpha(CustomerDAO.java:2351)
        at  .application.actions.SentenialAction.getCustomers(SentenialAction.java:364)
        at  .application.actions.CustomerAction.getAlphaCustomers(CustomerAction.java:235)
        at  .application.actions.CustomerAction.executeAction(CustomerAction.java:165)
        at  .application.actions.SentenialAction.execute(SentenialAction.java:73)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: <AST>: unexpected AST node: (
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1766)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1686)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
        ... 38 more
2006-04-25 18:07:41,484 ERROR tions.SentenialAction.getCustomers                   - Exception
.business.DataManagerException: Error getting customers by letter: 0-9 for client: 182
        at  .business.beans.customer.CustomerDAO.getCustomersByAlpha(CustomerDAO.java:2370)
        at  .application.actions.SentenialAction.getCustomers(SentenialAction.java:364)
        at  .application.actions.CustomerAction.getAlphaCustomers(CustomerAction.java:235)
        at  .application.actions.CustomerAction.executeAction(CustomerAction.java:165)
        at  .application.actions.SentenialAction.execute(SentenialAction.java:73)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ( [from  .business.beans.directdebitreference.DirectDebitReference as ddr where ddr.client.clientId = :clientId and ddr.directDebitReferenceStatus = :status and ddr.customer.businessCustomer = :busine
        at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:225)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
        at  .business.beans.customer.CustomerDAO.getCustomersByAlpha(CustomerDAO.java:2351)
        ... 29 more
Caused by: <AST>: unexpected AST node: (
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1766)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1686)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
        ... 38 more
2006-04-25 18:07:41 SESS Error - Caused by:
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ( [from  .business.beans.directdebitreference.DirectDebitReference as ddr where ddr.client.clientId = :clientId and ddr.directDebitReferenceStatus = :status and ddr.customer.businessCustomer = :businessStatus an
        at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:225)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
        at  .business.beans.customer.CustomerDAO.getCustomersByAlpha(CustomerDAO.java:2351)
        at  .application.actions.SentenialAction.getCustomers(SentenialAction.java:364)
        at  .application.actions.CustomerAction.getAlphaCustomers(CustomerAction.java:235)
        at  .application.actions.CustomerAction.executeAction(CustomerAction.java:165)
        at  .application.actions.SentenialAction.execute(SentenialAction.java:73)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: <AST>: unexpected AST node: (
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1766)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1686)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
        ... 38 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 8:13 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
It looks like the grammar for the where clause will only allow logical expressions, which in turn have to be made up of comparison expressions. Try changing making it into a comparison by comparing the regexp with 1:

Code:
from beans.directdebitreference.DirectDebitReference as ddr where ddr.client.clientId = :clientId and ddr.directDebitReferenceStatus = :status and ddr.customer.businessCustomer = :businessStatus and regexp(ddr.customer.businessName, '^[0-9]') = 1 group by ddr.customer.customerId order by  ddr.customer.businessName


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 1:42 pm 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
I actually tried that is well and got the same result. Any other ideas?

Thanks for all the help by the way, i really appreciate it


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 2:34 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Hmmm, I haven't got exactly the same setup as you but I just tried it locally with SQLServer and the regex function described here and adding any comparison (such as <> 0) avoided that error. For example, this query works on my local system:-

Code:
from Names as thisObj where regex(thisObj.First, 'Tom.*') <> 0


I'm using the current SVN version of Hibernate by the way - dunno if that makes a difference.

Cheers,
Rich.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.