From the course: Java Database Access with Hibernate

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Select clause

Select clause - Java Tutorial

From the course: Java Database Access with Hibernate

Start my 1-month free trial

Select clause

- [Instructor] There are three ways to retrieve objects from the database using the Hibernate framework. We have the Hibernate's criteria query API, HQL, and native SQL queries. Let's start with HQL. We're going to add some code. I've created a starting point for a project called QueryExample and I've placed it in the exercise files folder under Chapter 05 05_02. It looks very similar to the problem we used before. It still accesses the Hibernate example database, which has an employee table and a phone table. What we're going to do is we're going to use this to query information from those tables. At the top of this program, you'll see that I have my session factory being created, my service registry, and let's scroll down. On line 43, I'm opening a session. This is opening a session to establish a point for my queries. On line 48 is where I'm actually going to add my code. I don't need a transaction because I'm not actually going to persist anything into the database. For right now,…

Contents