In a relational database, data is represented as tables. In a Java program, data is represented as objects. For example, if you have data related to customers, you can store this data in a customers table. Similarly, you can store this data in objects which are instances of the Customer class. Object-relational mapping frameworks allow you to convert the data between these two systems.
We already learned how to fetch data via JDBC and the ResultSet interface in the previous chapter. You could take an instance of this interface, iterate over the rows, and manually set the fields of a Java class such as Customer. When you do so, you are doing the job of an ORM framework. Why reinvent the wheel? The Java ecosystem offers several options to fix the object-relational impedance mismatch. In the following sections, we'll examine three of...