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: joins for two tables
PostPosted: Tue Sep 01, 2009 12:52 pm 
Newbie

Joined: Wed Jun 24, 2009 11:34 am
Posts: 13
I have seen some tutorials that explain how to get joins to work between two tables, but I am not sure how to reference them correctly. Mostly because this tutorial does not tell what the fields are in the tables:
http://docs.jboss.org/hibernate/stable/ ... ryhql.html
But rather assumes you know the structure. Anyway, if I have a Material.java file which has @table(name=material) and a MenuMapping.java file, with @table(name = menumapping), how do I create a join of the two tables inside of the Material.java file. How does the material.java file know there is a table called menumapping? Or do I just reference the MenuMapping class (do I need to import it)? How do I set up the files to make these types of hql calls?


Top
 Profile  
 
 Post subject: Re: joins for two tables
PostPosted: Tue Sep 01, 2009 1:13 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Well, you need to know if you have a one to one, one to many, or many to many relationship between the entities. You should have foreign keys in your db, and you'll have instance variables for reference in your Java classes.

Here's a good tutorial on doing a one to many mapping with Hibernate:

http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=18mappingonetomanyassociations

That includes the ERD and the class diagrams, so you'll get a good idea for what is going on.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.