Background - data stores

Most applications talk to a variety of data stores. There has been a considerable evolution in how applications talk to a data store. The most basic API provided by Java EE is JDBC (Java Database Connectivity). JDBC is used to talk to relational databases from the first version of Java EE. JDBC is based on using SQL queries to manipulate data. The following is an example of typical JDBC code:

    PreparedStatement st = null; 
st = conn.prepareStatement(INSERT_TODO_QUERY);
st.setString(1, bean.getDescription());
st.setBoolean(2, bean.isDone());
st.execute();

Typical JDBC code contains the following:

  • The query (or stored procedure) to execute
  • The code to set parameters for query into statement objects
  • The code to liquidate ResultSet (the result of executing the query) into beans

Typical projects involved thousands of lines of JDBC code. JDBC code was cumbersome to write and maintain. Two frameworks became popular in an effort to provide an additional layer on top of JDBC:

  • myBatis (earlier called iBatis): MyBatis removes the need for manually writing code to set parameters and retrieve results. It provides simple XML or annotation-based configuration to map Java POJOs to a database.
  • Hibernate: Hibernate is an ORM (Object/Relational Mapping) framework. An ORM framework helps you to map your objects to tables in relational databases. The great thing about Hibernate is that developers do not need to write queries manually. Once the relationships between the objects and tables are mapped, Hibernate uses the mappings to create queries and populate/retrieve data.

Java EE came up with an API called JPA (Java Persistence API) that was roughly defined based on the popular ORM implementation at that time--the Hibernate framework. Hibernate (since 3.4.0.GA) supports/implements JPA.

In relational databases, data is stored in normalized, well-defined tables. While Java EE tried to solve the challenge of talking a relational data store, several other data stores became popular during the last decade. With the evolution of big data and real-time data needs, new and more unstructured forms of storing data came into existence. These kinds of databases are typically grouped under NoSQL databases. Examples are Cassandra (column), MongoDB (document), and Hadoop.

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

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