|
Hello Hibernate Experts,
i would very much appreciate your help in transforming the following SQL statement to a valid HQL Statement. I tried for hours but was not successfull:
SELECT * FROM master as m left outer join (select * from child as c where ...
Started by Markus on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Insert the SQL that correspond to your subrequest..
That formulas take SQL, not HQL.
|
|
Is there a way to create a Distinct query in HQL. Either by using the "distinct" keyword or some other method. I am not sure if distinct is a valid keywork for HQL, but I am looking for the HQL equivalent of the SQL keyword "distinct".
Started by Mike Pone on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If you....
(Names have been changed to protect identities)
String[] {startDate, endDate, bar});
It's worth noting that the "distinct" keyword in HQL does not map directly to the "distinct" keyword in SQL.
Here's a snippet of hql that we use.
|
|
If I write in HQL
A between 5 and 10
is that equivalent to
A >= 5 and A <= 10
or
A > 5 and A < 10
or some other of the 4 combinations?
Started by flybywire on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
So between in HQL is also.
In HQL is translated to the between operator in SQL, which is inclusive.
|
Ask your Facebook Friends
|
Where can I find a list of all HQL keywords?
Started by flybywire on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Try this ...not sure if it's complete or exact, but it may be, as it's a list of HQL tokens.
|
|
What is the recommended way to truncate a table using hibernate/hql?
I've tried this:
Query query = session.createQuery("truncate table MyTable"); query.executeUpdate();
But it didn't work (truncate doesn't seem do be documented anywhere in hql...)
Answer Snippets (Read the full thread at stackoverflow):
Works great:
public abstract class(); int rowsAffected = 0; try {... .
I used the delete syntax in an HQL to maintain portability.
String hql = String.format("delete from %s",myTable); Query query = session.createQuery(hql) return.
|
|
What are the pros and cons of using Criteria or HQL? The Criteria API is a nice object-oriented way to express queries in Hibernate, but sometimes Criteria Queries are more difficult to understand/build than HQL.
When do you use Criteria and when HQL?...
Started by cretzel on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
Criteria is an object-oriented API, while....
For different join types.
Also, HQL is a bit more powerful, I think, e.g.
On the other hand I'm using HQL for static and complex queries, because it's much easier to understand/read HQL.
|
|
Hello there. Does hibernate HQL queries support using select min, max, count and other sql functions?
like
select min(p.age) from person p
Thanks
Started by Danmaxis on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Are supported in HQL.
|
|
I'd like to "dry-run" Hibernate HQL queries. That is I'd like to know what actual SQL queries Hibernate will execute from given HQL query without actually executing the HQL query against real database.
I have access to hibernate mapping for tables, the...
Started by Juha Syrjälä on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For HQL, it's the same concept - you have to cast to Hibernate with a the 3.2-3.3 versions of Hibernate....
Update: for an offline, dry-run of some HQL, using HQLQueryPlan at this answer for Criteria Queries.
There has to be a better approach.
|
|
Is there any way to do the following in HQL:
SELECT case when flag = true then SUM(col1) else SUM(col2) FROM myTable
Started by lomaxx on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
End
Apparently the ability to do this was added in 3.0.4 , with the limitation that you ... .
Else ...
Then ...
End , and "searched" case, case when ...
Else ...
Then ...
When ...
I guess you can [inline edit] ...for where-clauses:
"Simple" case, case .. .
|
|
In HQL, how can I use bitwise operators? I want the resulting SQL query to look something like
SELECT RoleId, RoleName, RolePerms WHERE (RolePerms & @Parameter) = @Parameter
However, writing this HQL
select from Role where (RolePerms & :param) = :param...
Started by Husain on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Writing the HQL this way works:
select r from Role r where (r.Permissions & :param) > 0.
From section 13.8 of the NHibernate documentation , HQL does not support these bitwise operators to this.
|