It is important to remember that HQL talks about classes and fields, while SQL talks about tables and columns.
And if you specify an association, hibernation will automatically make connections for you. Imagine a class library that contains a list of books. Each book is in one library.
@Entity public class Library {
@OneToMany(mappedBy"library")
public List<Book> getBooks() {
return books;
}
...
}
@Entity public class Book {
@ManyToOne
public Library getLibrary() {
return library;
}
...
}
Then you can use hibernate to find the Library object for you, and you do not need to specify any connections. He just knows what to do (although you can often help him improve his performance if you give him more details).
Library library = entityManager.find(Library,1);
for (Book book : library.getBooks()) {
System.out.println("Found book: " + book.toString());
}
In my experience, you can do a lot using sleep mode without using "join" at all!
Learn more about annotations at http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/