-->
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.  [ 2 posts ] 
Author Message
 Post subject: Criteria for joining two tables
PostPosted: Mon Dec 08, 2014 5:25 am 
Newbie

Joined: Mon Dec 08, 2014 5:21 am
Posts: 1
select * from EMP e,DEPT d where e.dept_id=d.dept_id and e.dept_id="XXX";

can any body give me criteria for this query


Top
 Profile  
 
 Post subject: Re: Criteria for joining two tables
PostPosted: Wed Dec 10, 2014 9:42 am 
Newbie

Joined: Tue Dec 09, 2014 1:13 am
Posts: 2
Rakesh,

The type of SQL query you are describing in your example, is a theta-style query. This means that the relationship between tables is achieved not via a JOIN clause, but by specifying equal field values in the WHERE clause.

The normal thing to do in Hibernate, would be to map your Employee and Department classes to database tables, and to indicate (via annotations or configuration files) which one is a collection contained on instances on the other. In your example, we can assume that a Department has many employees.

Hibernate uses that information in order to build SQL joins internally. In a Criteria, you start with one specific class, and then attach code for the other, building on that SQL JOIN clause that Hibernate had already figured out, based on your configuration.

That's why your question doesn't really make much sense. If you have no one-to-many relationships (i.e. no joins) defined in your configuration, and that is the reason you have to use a theta-style join, then it doesn't make sense to use a Criteria.


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