Chapter 7. Data access in OSGi with Spring DM

 

This chapter covers

  • Accessing data from relational databases with Spring DM
  • Using JDBC and JPA with Spring DM
  • Avoiding specific pitfalls and resolving problems when using JPA with Spring DM
  • Implementing transactions within OSGi applications with Spring DM
  • Using the “open element in view” pattern, within OSGi applications with Spring DM

In the previous chapter, we showed you how to prepare third-party frameworks and libraries for use in an OSGi environment and how to organize the bundles of your enterprise applications. You also saw that developing enterprise applications with OSGi is slightly different than for classical Java applications, especially with regards to data access.

In this chapter, we’ll focus on this last topic and describe how to implement data access components using standard Java technologies, such as Java Database Connectivity (JDBC) and Java Persistence API (JPA), within an OSGi environment using Spring DM. OSGi has some constraints regarding the implementation of these technologies, and we’ll look at how to address them and the pitfalls to avoid.

The last subject we’ll tackle in this chapter is that of transactions. We’ll see how to use Spring DM and the OSGi service registry to make transactions work smoothly.

7.1. Using JDBC within OSGi with Spring DM

7.2. Using ORM within OSGi with Spring DM

7.3. Transactions

7.4. Using the open EntityManager in view pattern

7.5. Summary