Hi guys
How can I use something like
Code:
select * from(...)
on sub select in HQL query ?
My motivation for it is that i need to use order by and limit the number (omitted at this point) of returned rows from inner select.
While the sorted and reduced rows will be part of "in" expression of wrapping query
In regular SQL with little help from Oracle row)number function it looks like this
Code:
select
/* user fields */
from
/* user table */
where
userCondition.category in (
select
all.category,
order by all.CREATED_DATE asc)
from
(
select definition.category, CREATED_DATE
from
Event
where Event.typeId = definition.typeId
Event.CREATED_DATE>=? and
Event.CREATED_DATE<=?
)
all
)
what i am trying to do is the following query,
while the "Event.definition.category.id from" line fails with Query syntax exception
Code:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token
Code:
select u
from User as u
join u.conditions as conditions
where conditions is not empty
and conditions.category.id in (
Event.definition.category.id from (
select op.definition.category.id from Event op
where op.createdAt >= :timeFrom and op.createdAt <= :timeTo
order by op.createdAt
)
)
thx