-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Is this query possible?
PostPosted: Fri Mar 12, 2004 11:12 am 
Newbie

Joined: Fri Mar 12, 2004 11:00 am
Posts: 3
Location: Montr
Hi,

I'm new to Hibernate and am wondering if the following query is possible with Hibernate's OQL or HQL:

Here is my object model:

C-M------1-B-M------1-A
|
/\
--
|
D

i.e. A has a 1-M association with B, B has a 1-M association with C and
D is one subclass of C

The query that I like to perform is this:

find all A's with aAttribute = "foo" AND
having a C with cAttribute = "bar" AND
having a D with dAttribute = "foobar".

Of course, it would be nice if the query could translate into one SQL statement.

Your response would be most appreciated,

Phil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 2:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
For sure, not until 2.2 (in cvs only).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 3:45 pm 
Newbie

Joined: Fri Mar 12, 2004 11:00 am
Posts: 3
Location: Montr
Thanks. What would the HQL look like? Does this work in the current cvs head?

Phil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 3:47 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hibernate v22branch is not even alpha, it doesn't work with current versions.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 3:50 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
select a from A as a join a.Bs as b join b.Cs as c where a.attribA = "foo" and c.attribC = "bar" and <don't have class casts yet>.attribD = "baz" would be the syntax.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 3:59 pm 
Newbie

Joined: Fri Mar 12, 2004 11:00 am
Posts: 3
Location: Montr
Is it the ability to cast that is going to be available in 2.2 and is that what Emmanuel was referring to?

Phil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 4:00 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
We had a discussion about the cast in HQL on the developer list last week, yes, it will be in a future release. I don't know what Emmanuel is talking about either ;)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 7:19 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
christian wrote:
We had a discussion about the cast in HQL on the developer list last week, yes, it will be in a future release. I don't know what Emmanuel is talking about either ;)

Yes, I must confess I did a short answer :)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.