In majority of applications, it is usually necessary to persist objects between sessions. Traditionally this has been done in Java by using the JDBC APIs.
Note
The JDBC (Java Database Connectivity) API provides a set of APIs for accessing relational databases such as Oracle and MySQL. Further details of these APIs can be found at:
However, there are several drawbacks to using the JDBC APIs, as follows:
SQL statements (such as select, insert, and update) are generally written to be database specific. When an application is required to run against a different database engine, these SQL statements often need to be amended.
The code for accessing different tables tends to be almost the same. Therefore, a lot of copy-pasting of code occurs.
SQL can be verbose and unwieldy. When entities have more than a few properties, SQL statements can become very unwieldy. Typically, parameters in SQL statements are referred...