[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6253) Registered function not being called
Sebastian H. (JIRA)
noreply at atlassian.com
Thu May 26 10:57:25 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42419#action_42419 ]
Sebastian H. commented on HHH-6253:
-----------------------------------
Seems like I cannot use registered functions in the WHERE clause.
> Registered function not being called
> ------------------------------------
>
> Key: HHH-6253
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6253
> Project: Hibernate Core
> Issue Type: Bug
> Components: core, query-hql
> Affects Versions: 3.6.3, 3.6.4
> Reporter: Sebastian H.
>
> Using the following SQL Dialect
> public class ServiceAppMySQL5InnoDBDialect extends MySQL5InnoDBDialect {
> public ServiceAppMySQL5InnoDBDialect() {
> super();
> registerFunction("bitwise_and", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "(?1 & ?2)"));
> registerFunction("hasflags", new SQLFunctionTemplate(StandardBasicTypes.BOOLEAN, "?1 & ?2 = ?2"));
> }
> }
> and HQL query
> Query q = em
> .createQuery(
> "SELECT o FROM "
> + entityClass.getName()
> + " o WHERE hasflags(o.status, :status)")
> .setParameter("email", username)
> .setParameter("status", status.getBitmask());
> results in the following exception
> Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ( near line 1, column 50 [SELECT o FROM tv.px.domain.Owner o WHERE hasflags(o.status, :status)]
> at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
> at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
> at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
> at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261)
> at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
> at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
> at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
> at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
> at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
> at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
> at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:272)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list