One of the very important aspect in any enterprise application is the ability to get data in and out of your application with ease. Thinking on the same lines, Spring framework provides extensive support for data access. In this Chapter we will first explore the various data access technologies and then see the support provided by Spring for using these technologies in your application.
Spring effectively makes data access easier by managing the various resource for you, by providing abstraction and easy API helpers and by supporting all major data access technologies available in the industry so that you don’t have to get yourself bogged down to a particular technology. Going along with the Spring philosophy it lets your Spring application integrate to any data access technology with ease.
In this Chapter we will see the support given the Spring framework in interacting between data access layer and the service layer in your application. Spring compressive support for transaction management will be covered briefly as we have dedicated Chapter 9 for this specific topic. In this chapter we will also be covering various data access frameworks and technologies which the Spring framework integrates with almost ease.
Enterprise Data Access
Spring integrates and works just fine with all leading data access technologies at present available in market. Accessing eternal system like a database requires various resources at various stages. You will also have to look for resource contention and make sure that resource which is limited is managed properly and efficiently. Such resource management becomes critically important in mission critical enterprise application.
Putting the burden of maintaining these resources in an application to a developer not only puts additional pressure in a developer but also puts an additional risk on the overall application’s success. Spring provides comprehensive resource management capability which takes this burden away from the developer and entrust him with writing the actual business application logic.
As discussed earlier Spring integrates seamlessly with almost all data access technologies like JDBC, Hibernate, iBatis, JPA or JDO in a consistent way. Using Spring, you are not locked down to a particular technology and as case may be, you have the freedom of switching between the various technologies without worrying too much about the technology specific nitty-gritties. Figure 8-1 also shows the various classes which will be used to in the code samples in this chapter in various sections.
Figure 8-1. Spring Integration with well know data access technologies
Spring internally take care of the various resource management functionalities specific to data access technologies so that the developer concentrates on the actual application logic rather than data access technology specific coding.
Some of the key features which the Spring framework provides in resource management are:
- Transaction Management
- Connection Management
- Exception Handling
In a typical application, the resource management capabilities are related with connection and transaction management. While trying to manage connection and transaction, there are exceptions that arise and resource management should also be capable of dealing these exceptions in timely and orderly fashion. Figure 8-2 shows a typical resource management scenario in an application.
Figure 8-2. A typical resource management scenario in any application
The following sections will look into these features of Spring in some detail so that you get a clear picture of what are the features which Spring transparently does for you in developing your application.
Page Visitors: 9421