Keyword UNION is prefixed with "this_." in filter conditions

Description

I need to use a UNION-Subquery in a Filter condition unless is solved.
But anyway, when using the keyword "union" in the Filter condition it is prefixed with "this_.".

For instance, this ...
@Filter(name = "resellerFilter", condition = "(select cu.resellerId from Customer cu, GeoNumber gn where (cu.id = gn.customerId and gn.id = this_.geoNumberId) UNION select cu.resellerId from Customer cu where cu.detemeTemplateId = this_.id) in (null, :resellerIds)")

... produces this ...

select
...
from
DeTeMe this_
where
(
select
cu.resellerId
from
Customer cu,
GeoNumber gn
where
(
cu.id = gn.customerId
and gn.id = this_.geoNumberId
) this_.UNION select
cu.resellerId
from
Customer cu
where
cu.detemeTemplateId = this_.id
) in (
null, ?
)
and this_.id = ?

Environment

Oracle 10g: org.hibernate.dialect.OracleDialect
Suse Linux
Hibernate: 3.2.1.ga
Hibernate Annotations: 3.2.1.GA

Activity

Show:
Frederic Leitenberger
April 30, 2007, 6:55 PM

For the time being, i found another solution for my query without UNION:

@Filter(name = "resellerFilter", condition = "(select distinct cu.resellerId from Customer cu, GeoNumber gn where cu.id = gn.customerId AND gn.id = geoNumberId OR cu.detemeTemplateId = id) in (null, :resellerIds)")

... results in ...

select
...
from
ICCS6.DeTeMe this_
where
(
select
distinct cu.resellerId
from
Customer cu,
GeoNumber gn
where
cu.id = gn.customerId
AND gn.id = this_.geoNumberId
OR cu.detemeTemplateId = this_.id
) in (
null, ?
)
and this_.id = ?

But the execution-time is even worse ...
Best would be to be reopened and solved.

Steve Ebersole
October 3, 2007, 6:19 AM

Oddly enough, UNION is not always prefixed with the alias.

I started with a simple UNION (sub)query as the filter condition and it worked fine.

The only way I could get this to occur given my test case was to add parens around the stuff right before the UNION (just like your's had). In your query and mine, the parens are not required so there is an easy workaround...

Steve Ebersole
October 3, 2007, 6:55 AM

fixed on 3.2/trunk

Frederic Leitenberger
October 3, 2007, 1:09 PM

Thanks. That's great news (both).

Steve Ebersole
March 21, 2011, 7:05 PM

Bulk closing stale resolved issues

Assignee

Steve Ebersole

Reporter

Frederic Leitenberger

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Trivial
Configure