Hi,
I have posted a question few days ago about Querying on collections with the Criteria API and after all the answers i see that the thing that i am trying is not possible with the Criteria, there is a bug for the situation in nhibernate and also in hibernate
I was using DetachedCriteria to get all criterias together and the list is ...
What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?
Also what is the non-HQL way for saying give me the first 15 of a class?
...
Was thinking about a scenario, suppose two entities, Customer and Order. Suppose I want to see all distinct customers who fulfills a certain criteria, who has one or more orders fulfilling a criteria.
If I use something like:
Select distinct cust from Customer cust join cust.orders order where order.x = 'y' and cust.z = 1
The above ...
Given the following HQL Query:
FROM
Foo
WHERE
Id = :id AND
Bar IN (:barList)
I set :id using the Query objects' setInteger() method.
I would like to set :barList using a List of objects, but looking at the Hibernate documentation and list of methods I cannot see an obvious choice of which to use. Any ideas?
...
Using HQL, I would like to search for the starting index of sequenced objects.
For example, if I have the following persisted classes:
<class name="Word">
<id name="id" type="int">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<many-to-one name="sentence" class="Sentence"/>
<property name="...
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?
...
Where can I find a list of all HQL keywords?
...
I want a single HQL query that returns all groups containing a given user that where created before a given date. Somehow I can't get it right.
public class Group
{
@ManyToMany
Set<User> users;
Date created;
}
public class User
{
...
}
...
I'm trying to write an HQL query to select objects which contain an object in a child collection.
Example:
Contest Object
ContestID
ContestName
RequiredCountries -> one to many collection of Country objects
Country Object
CountryCode
CountryName
The sql equivalent of what i want:
SELECT * FROM CONTEST C
WHERE C.CONTESTID IN(SELE...
I tried this:
from Table where (:par1 is null or col1 = :par1)
but it happens that
from Table where :par1 is null
always returns all the rows of the table, even if the :par1 is not null.
while
select * from table where col1 = 'asdf'
does not return any row.
I can't use native grammars because my application is supposed to run...
Is there a way to externalize HQL named queries to an external file. I have too many named queries and using @NamedQueries/@NamedQuery at the head of my entities classes is hurting.
Is there a way to externalize to several files?
...
I am new to HQL and have the following table relationships:
Term has many Definitions
Definition has many DefinitionProducts
DefinitionProducts has one Product
I want to get the list of Terms that have at least one Definition that has at least one DefinitionProduct that has a specific Product
This is my best attempt (in Grails):
Te...
I need to do something like the following:
select d.ID,
count(from Lead l where l.DateCreated > DATEADD(day, -30, :todays_date) AND l.DealerId=d.ID),
count(from Lead l where l.DateCreated < DATEADD(day, -30, :todays_date) and l.DateCreated >= DATEADD(day, -60, :todays_date))
FROM Dealer d
GROUP BY d.ID
Ordinarily I could do this:
SE...
I'm looking how to perform date/time math within an HQL query. Specifically, how do I add or subtract (x) amount of time from the result of the current_timestamp() function? Or do I have to drop into SQL for this and hope that whatever database is being run supports it?
HQL query example:
FROM RandomThing
WHERE randomTime IS NOT NULL A...
I have 2 entities: car and wheels (oneToMany) and I want to retrieve my car, with all the wheels and (this is the tricky part) ordered by wheels.location.
Select c from Car LEFT JOIN FETCH c.wheels order by c.wheels.location doesn't work:
"illegal attempt to dereference collection".
Any idea how to do this and if this is possible in HQ...
and have it map to a strongly typed object?
Suppose I have a entity Blog with Id,Name,Posted,IsUglyFace,YerMom
but I just only want/need Name and Posted columns. I tried to do something like:
IList blogs = repository.SimpleQuery("select Name, Posted from Blog");
This dumps out a ton more SQL and gives back an error, could not map to...
Hi all,
I'm in process of migrating an old "classic ASP" application to J2EE/Hibernate.
I have a problem with the following type of SQL statements:
SELECT parent.id, parent.name, parent.column1, count(child.id) AS no_of_children
FROM parent
INNER JOIN child ON child.parent_id = parent.id
GROUP BY parent.id, parent.name, parent.column...
I'm trying to get a specific set of data while joining 4 different entities together to do so. What I've done is setup a DTO to try to get this working:
public class LatestThread
{
private readonly string comment;
private readonly DateTime posted;
private readonly string userName;
private readonly int reputation;
private readonly ...
How would you express the following Criteria query in HQL?
var idArray = new int[] { 1, 2, 3, 4, 5 };
Session.CreateCriteria(typeof(Foo))
.Add(Expression.In("Id", idArray)
.List<Foo>();
I am aware of that there is an "in" keyword in HQL, but as I understand it that keyword is for use with subqueries rather than something like...
With HQL I can use dynamic instantiation like this:
select new ItemRow(item.Id, item.Description, bid.Amount)
from Item item join item.Bids bid
where bid.Amount > 100
Now I need to create my queries dynamically with the Criteria API. How can I obtain the same results that I would have obtained with HQL, but using the Criteria API?
Th...