The Object Relational Mapping (ORM) is a technique that maps the data represented in object type into relational model with a database schema. The Hibernate is an open source ORM tool for Java; it maps Java Objects into database objects such as tables. Hibernate also provides powerful querying tool that does the reverse process, converting database objects into Java objects. It simplifies the database interactions very much; otherwise the developers have to write complex JDBC statements. It is object oriented so that the developers can enjoy the features of Object Oriented Programming System (OOPS) features in handling data on any database. Hibernate provides transparent persistence and Object-Oriented Query Language which is independent of any database. Hibernate supports native SQL queries as well. The Chapter 1 (Getting Ready) make you get ready to work with Hibernate. It explains the installation procedure of Hibernate and other required supporting software tools such Java, Database, and Integrated Development Environment (IDE). This chapter introduces you the need of Hibernate and its architecture. It describes how to download and install supporting software components to work with Hibernate programs. The database MySQL is used for database interaction examples. However, the users may use other RDBMS databases, with minor changes in programs. The procedure for other databases is also given in this chapter. Like this, the user is not compelled to use only Tomcat as Application server and Eclipse as Java IDE. The Chapter 2 (Persisting Student Data with Hibernate: Demo) demonstrates a complete working example with Hibernate. It explains how to insert one record of Student information into database table using Hibernate. Based on this example, this chapter explains briefly about the configuration details and required setups to work with Hibernate such as Creating database user, Creating Java Project in Eclipse, Setting up the required Hibernate and other library files with Eclipse, and Defining Hibernate configurations. The configurations are to be followed for examples shown in other chapters. The Hibernate API used this chapter are not explained in this chapter itself, but explained in the next chapters in detail. The Chapter 3 (Hibernate Session) introduces working with Hibernate Sessions. All data definition and manipulation should be done in Hibernate through Session. Any object should be present in the Session before it is interacted with database. The Hibernate Session Factory acts a database connection pool and Hibernate Session acts a Connection, if it is compared with JDBC. The Hibernate Session Factory is used to provide Hibernate Session(s), which are used to do relational mappings of objects such as definition and manipulation of data with database.
Additional Info
  • Publisher: Laxmi Publications
  • Language: English
  • ISBN : 978-93-83828-34-0
  • Chapter 1

    Getting ready Price 2.99  |  2.99 Rewards Points

    Hibernate is an Object Relational Mapping (ORM) tool, which is an Open Source. It maps objects (Java) with relational data (RDBMS) and vice versa, i.e., maps the Java classes to the database tables. So you can utilize the full features of Object Oriented Programming System (OOPS) in handling data on any database. Hibernate provides transparent persistence (storage) and Object-Oriented Query Language which is independent of any database. You can invoke native SQL queries (queries belonging to a particular database) as well.
  • Chapter 2

    Persisting student data with hibernate: demo Price 2.99  |  2.99 Rewards Points

    Some initial setups are required to work with Hibernate such as locating library files, configuring data sources, and defining persistence (storage) objects. This chapter demonstrates these initial configuration things with a simple program. These same Hibernate configurations are to be followed in other chapters.
  • Chapter 3

    Hibernate session Price 2.99  |  2.99 Rewards Points

    All data definition and manipulation should be done in Hibernate through Session. Any object should be present in the Session before it is interacted with database. The Hibernate SessionFactory acts a database connection pool and Hibernate Session acts a Connection, if you compare with JDBC. This chapter explains the uses of SessionFactory and the important methods in Session which are used for relational mappings of objects with database.
  • Chapter 4

    Defining pojos using jpa/ hibernate annotations Price 2.99  |  2.99 Rewards Points

    A POJO (Plain Old Java Object) is a Java object that doesn't extend/implement any framework specific classes/interfaces. The POJOs look like a simple Java beans; they decouple your application code from any framework that you are using. JPA/Hibernate Annotations: We have to specify metadata information (such as name of the database table, column names, length of the columns, data types, etc.) while using JPA/Hibernate persistence. Specifying metadata through XML is a common one; however, we can best use the annotation features of latest JPA/Hibernate API. While using Annotations, no need to depend on XML since the annotations (they are also Java classes) are compiled into Byte code and invoked during runtime using Java Reflection API. Some important JPA/Hibernate annotations for defining required POJOs (entities) are described below. The JPA can be also be used in EJB 3, keeping this flexibility in mind, many JPA annotations are used in the examples even though Hibernate equivalents are available.
  • Chapter 5

    Hql/jpaql Price 2.99  |  2.99 Rewards Points

    HQL (Hibernate Query Language) is powerful object-oriented query feature supported by Hibernate. The syntaxes of HQL are similar to SQL, but not the same. HQL is independent of underlying database. Hibernate generates native SQL query for every HQL. The Java Persistent API Query Language (JPAQL, simply JPQL), based on EJB 3.0 standard, is an extension of EJB QL (Enterprise Java Bean Query Language) and has many features than EJB QL. It is also a database independent object-based query language. And it is a subset of HQL so that all JPAQL queries are valid in HQL.
  • Chapter 6

    Criteria queries Price 2.99  |  2.99 Rewards Points

    Even though the HQL is based on object references, its query syntaxes are similar to SQL, so the programmer still needs to know SQL syntaxes and relational mappings to write HQL queries. The Hibernate provides Criteria API which is purely based object-oriented approach; using this Criteria API, the programmer can use Java code for manipulating data with database, and no need to know SQL and relational mappings for building queries.

About the Author

Other Books by Author