Data layer

Most applications talk to a database. The data layer is responsible for storing data from your Java objects to your database and vice versa. The following are the most popular approaches to building data layers:

  • JPA: The Java Persistence API helps you to map Java objects (POJOs) to your database tables. Hibernate is the most popular implementation for JPA. JPA is typically preferred for all transactional applications. JPA is not the best choice for batch and reporting applications.
  • MyBatis: MyBatis (previously, iBatis) is a simple data-mapping framework. As its website (http://www.mybatis.org/mybatis-3/) says, MyBatis is a first class persistence framework with support for custom SQL, stored procedures and advanced mappings. MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can be considered for batch and reporting applications where SQLs and stored procedures are more typically used.
  • Spring JDBC: JDBC and Spring JDBC are not that commonly used anymore.

We will discuss in detail the advantages and disadvantages of JDBC, Spring JDBC, MyBatis and JPA in Chapter 8, Spring Data.

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

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