Suquery not working correctly with <framework:restrictions>
-----------------------------------------------------------
Key: JBSEAM-3302
URL:
https://jira.jboss.org/jira/browse/JBSEAM-3302
Project: Seam
Issue Type: Feature Request
Components: Framework
Environment: Windows XP
Reporter: Tim Timson
I have created a query in components xml and added a restriction using the
<framework:restrictions> tag. The restriction should add a where clause, but
instead it is adding an "and", thinking the "where" is already in
place. I assume this is because there is a "where" statement in a subquery
contained in the ejbql.
Here is the entry in components.xml which causes the error.
<framework:entity-query name="eventPricedItemsQuery"
ejbql="select pricedItem,
(select sum(cartEntries.amountCharged)
from Cart as cart
join cart.entries as cartEntries
join cartEntries.item as item
where pricedItem.id = item.id)
from PricedItem pricedItem">
<framework:restrictions>
<value>pricedItem.event = #{currentEvent}</value>
</framework:restrictions>
</framework:entity-query>
I can work around it by removing the restriction and adding a where clause to the ejbql,
but have reasons for wanting to use the <framework:restrictions> tag instead.
Here is some of the stack trace I used to determine that an "and" was being
placed into the query by Seam when a "where" should have been created:
Caused by: javax.el.ELException: /events/registration-report.xhtml @29,71
value="#{eventItems}": java.lang.IllegalArgumentException:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: and near line 1, column 879
[select pricedItem, (select
sum(cartEntries.amountCharged) from
com.el.sbo.model.user.Cart as cart join
cart.entries as cartEntries join cartEntries.item as
item where pricedItem.id = item.id)
,(select count(cartEntries.amountCharged)
from com.el.sbo.model.user.Cart as cart
join cart.entries as cartEntries join
cartEntries.item as item where pricedItem.id =
item.id) from
com.el.sbo.model.event.PricedItem pricedItem and pricedItem.event = :el1]
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
at javax.faces.component.UIData.getValue(UIData.java:582)
... 68 more
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException:
unexpected token: and near line 1, column 879 [select pricedItem,
(select sum(cartEntries.amountCharged)
from com.el.sbo.model.user.Cart as cart join
cart.entries as cartEntries join cartEntries.item as
item where pricedItem.id = item.id)
,(select count(cartEntries.amountCharged)
from com.el.sbo.model.user.Cart as cart
join cart.entries as cartEntries join
cartEntries.item as item where pricedItem.id =
item.id) from
com.el.sbo.model.event.PricedItem pricedItem and pricedItem.event = :el1]
at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:617)
at
org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
at
org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:79)
at
org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.createQuery(FullTextEntityManagerImpl.java:130)
at
org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:79)
at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:175)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira