-->
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.  [ 4 posts ] 
Author Message
 Post subject: Retrieve data from multiple tables.
PostPosted: Tue Apr 12, 2005 1:00 am 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
What are the best approach to retrieve data from multiple tables with join conditions. (If you want do not want to use HSQL much).

Is only HSQL is the only option to get data from multiple tables when you have join like
Example Select empno, ename, dept from emp, dept where emp.empno = dept.empno

Can we give multiple tables with CreateCriteria ?

Please let me know your suggestions. Right now we are not using Hibernate 3 yet.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 1:51 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Describe the realations in your hbm.xml file and navigate them in Java. That's what a ORM tools are made for.

Only if you have many objects on the n side of a relation you have to load them with restricting HQL or Criteria API in order not to hit any performance/memory problems. But having the relations described in your hbm.xml file still helps a lot here.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 12:33 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
If you need to get data from multiple tables :- > Is HSQL is only option or can we use any other approach?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 1:29 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
Ok,
I got my answer.

I can use createCriteria to retriev data from mulitple tables.

Code:
Criteria itemCriteria = session.createCriteria(Item.class);
itemCriteria.add( Expression.like("description",
"gc",
MatchMode.ANYWHERE) );
Criteria bidCriteria = itemCriteria.createCriteria("bids");
bidCriteria.add( Expression.gt( "amount", new BigDecimal("100") ) );
List results = itemCriteria.list();


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