Chapter 2. Understanding the Fundamentals

In this chapter, we will cover the following recipes:

  • Building a SessionFactory
  • Creating a generic SessionFactory provider class
  • Opening a new session
  • Opening a stateless session
  • Saving an object to the database
  • Fetching an object from the database
  • Removing an object from the database
  • Updating an object
  • Creating a criteria
  • Restricting the results using a criteria
  • Pagination using a criteria
  • Sorting the results
  • Transforming a result
  • Using basic projection

Introduction

Before we proceed, it's necessary to learn about the fundamentals of hibernate: the classes and interfaces required.

In this chapter, we will cover the fundamentals of hibernate, such as SessionFactory, Session, and Criteria. We will discuss the importance of SessionFactory in the hibernate application. Criteria is used to do the actual transaction or the CRUD (Create, Read, Update, Delete) operation. Apart from this, we will cover some basic and useful functionalities, such as the sorting of results, limiting the number of rows, transforming a result, and the basics of projections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.144