A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Elasticsearch in Action
this week in the
Object Relational Mapping
any good hql query for this scenario?
Joined: Mar 01, 2008
Sep 07, 2009 20:45:16
Another query to ask here. we have a table
File(name ,date, file_size).
anyone has simple query to list name of file where the related size is not 0
let me give some sample data.
name date size
a 1/1/2001 0
a 2/1/2002 2
a 3/3/2003 0
b 1/1/2000 3
b 2/2/2001 4
If I run the query, it should list "b" only as "a" has two related size = 0.
I know the sql for it. but seems contain subquery and complex. so I am after a simple HQL
Thanks in advance.
the sql would be
select name from File where size>0 and name not in (select name from File where size=0)
I gotta keep learning...
Joined: Sep 17, 2009
Sep 22, 2009 21:29:00
Not sure why you need the SubQuery
HQL = "from File where size>0" seems sufficient to me as this query will return only Files whose size is > 0. Unless the data that you provided is wrong and there are cases where the File Name is same but the size maybe 0 or other values
I agree. Here's the link:
subject: any good hql query for this scenario?
JPA native Query - Select... where... IN, How to set list of values to setParameter()?
Seeking help on a complex SQL I reckon, wish get a simple one from answer
how to dynamically set values in check box
inconvertible types found : int required: java.lang.Short
JSP attendance management project error
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015