lakemalcom
lakemalcom

Reputation: 1066

Does Hibernate HQL support aliasing subqueries?

I'm using Hibernate 3.2.6 and I'm attempting to make a query like so:

select 
    a, 
    (select min(date) as someAlias from B b where a.id = b.id)
from A a
    where someAlias is not null and someAlias between :start and :end

Imagine that this query makes sense in the context that I'm operating in. When I run this query, I get an error saying "Unknown column 'someAlias' in 'where clause'". When I show the SQL output, I see that SQL doesn't seem to include the 'as someAlias' part of the query.

Is this just unsupported, or am I missing something? Or this just a feature not supported in version of Hibernate?

Upvotes: 0

Views: 2808

Answers (1)

Adisesha
Adisesha

Reputation: 5258

Translate the query to native sql and fire it on db, it will not work.It is not a valid query because aliases in select clause will not be visible in where clause.

Aliases are supported in HQL.

Upvotes: 2

Related Questions