|
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):
SELECT CASE ps.open WHEN true THEN 'OPEN FROM ParkingState as ps
This is an example using a string comparison in the condition:
SELECT CASE f.type is supported in the where....
A boolean value with the corresponding textual representation.
|
|
Hi im a newbe to HQL and have a SQL expression I need converted but am unable to select the SQL statement is:
select SenseDate as Time,SenseValue as Value from UserData where NetworkID = '23' and IODeviceID = '129' and SenseDate >= DateAdd("d",-1, ...
Started by Patrick Nevin on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Looks like the following:
select SenseDate" />
And then, you....
select new Family(mother, mate, offspr) from Eg.DomesticCat-in-Depth/1/
You can select fields/columns using HQL.
I think HQL has the "new" keyword now.
|
|
How can HQL be used to select specific objects that meet a certain criteria?
We've tried the following to generate a list of top ten subscribed RSS feeds (where SubscriptionCount is a derived property):
var topTen = UoW.Session.CreateQuery( @"SELECT distinct...
Started by jmcd on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
]; }
If you change your HQL a bit to look like that:
var topTen = UoW.Session.CreateQuery( @"SELECT distinct is an example from the NHibernate docs:
IEnumerable results = sess.Enumerable( "select cat.Color, min.
|
Ask your Facebook Friends
|
I have a table in mysql which has just on record. when I execute following hql query in netbeans HQL I got the following answer which is correct:
query:
from Customer as cust
response:
CustomerID PhoneNumber MainAddress SubAddress RequesstNumber Name ...
Started by JGC on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You write:
from Customer as cust
it litterally means that you select all columns:
select.
|
|
I want to delete certain records from a table. These records have some child-records in other tables.
In order to be able to delete the main records, I have to delete the child records first.
Here is the example of the HQL used:
delete from ItineraryBooking...
Started by Stefan Hendriks on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Are you flushing the session after executing....
From the hibernate manual :
No joins, either implicit or explicit, can be specified in a bulk HQL this HQL in a transaction? selects doesn't need a transaction, but deletes does need it.
|
|
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):
The query could be something much simpler, like:
SELECT m.id, max(c.id) FROM master as m left join; ):
SELECT new Master(m.id, max(c.id)) FROM master as m left join m.childs as c group by m.id
2 that formulas take SQL, not HQL.
|
|
Is there any way to use expressions in the Select clause?
E.g.:
select u.Age/2 from User u
I'm having this exception right now:
NHibernate.QueryException: ',' expected in SELECT before:/ [select u.Age/2 from Business.Entities.User u]
Started by Hernan on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Divided by two? You can use HQL but I find it's easier to change the formula attribute in the mapping.
|
|
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):
(Names have been changed to protect identities)
String queryString = "select distinct f from Foo f inner join foo.bars as b" + " where f.creationDate >[] {startDate, endDate, bar});
It's worth noting....
Here's a snippet of hql that we use.
|
|
I have a query which returns a list of objects like such:
select distinct ref from references where [...]
I'd like to order these by a field not on ref but on an association of ref, i.e.:
select distinct ref from references where [...] order by ref.foo...
Started by wds on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
In the selection:
SQL> select ename from emp 2 order by empno 3 / ENAME CLARKE VAN WIJK PADFIELD ROBERTSON; select distinct ename from emp 2 order by empno 3 / order by empno * ERROR at line 2: ORA-01791.
|
|
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.
|