-->
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.  [ 7 posts ] 
Author Message
 Post subject: how to write criteria query with join for unassociated entit
PostPosted: Thu Feb 02, 2006 7:08 am 
Regular
Regular

Joined: Fri Dec 17, 2004 10:38 am
Posts: 54
Hello!

I have a problem to convert hql query to criteria query
HQL query:

Code:
from User user join UserGroups userGroups where userGroups .group = ?


it quite easy for associated classes (User and Group in my case) - you just create subcriteria and add expressing.
But i have NO ASSOCIATION between classes.
How can i write such criteria?

Thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 9:02 am 
Regular
Regular

Joined: Fri Dec 17, 2004 10:38 am
Posts: 54
or even more- how to write Theta-style join criteria query for hql query like

Code:
from User user, LogRecord log where user.username = log.username

Except from Hibernate in Action


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 7:39 pm 
Newbie

Joined: Fri Feb 03, 2006 7:23 pm
Posts: 2
Hey fuzebest

I have got nearly the same problem. I my design I associate classes via id like:

class Item
id:Long
name:String

class Bid
id:Long
itemId:Long
amount:BigDecimal

Where the Bid::itemId is a foreign-key to Item::id in database.

My problem is how do I/ can I make a serch criteria which joins the two classes?
Something like?

List result = session.createCriteria(Bid.class)
.createAlias("items", "ITEM").
.add( Expression.eq( "ITEM.id", "42" ) )
list();

Where do I tell the criteria the association between the table ITEM and BID? Can it be done in the creiteria it self or is there a way to put the association in the hbm file?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 11:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
that is not supported


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 04, 2006 9:37 pm 
Newbie

Joined: Fri Feb 03, 2006 7:23 pm
Posts: 2
Thanks for the fast and prompt reply and I promise to be more carefull with typing correctly. I will have to implement the search in plain SQL then to work around the join-in-criteria-problem.

Do Hibernate have plans for such a feature in the future? Could come in handy when implementing Hibernate to support new features where Hibernate entities have to interact with non hibernated entities in existing systems running a different strategy towards the database.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 04, 2006 10:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
This makes no sense. Hibernate would still need to know about these other entities.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 8:29 am 
Regular
Regular

Joined: Fri Dec 17, 2004 10:38 am
Posts: 54
and there are no support for Theta-style joins either?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.