Nonfiction 3

Spring Persistence — A Running Start by Paul Fisher, Solomon Duskis

Posted On February 25, 2017 at 6:38 am by / Comments Off on Spring Persistence — A Running Start by Paul Fisher, Solomon Duskis

By Paul Fisher, Solomon Duskis

Show description

Read Online or Download Spring Persistence — A Running Start PDF

Similar nonfiction_3 books

Adenosine Receptors and Parkinson's Disease

This e-book is the 1st definitive evaluation on adenosine receptor antagonists and their software to the therapy of Parkinson's sickness. The influence of those novel non-dopamine medications on vitro and in vivo platforms essentially indicates their power for the remedy of this debilitating illness. This e-book covers how the Parkinson's disorder antagonist drug, A2A, has been researched, constructed, and proven.

Extra resources for Spring Persistence — A Running Start

Sample text

JdbcTemplate = new JdbcTemplate(dataSource); } } The preceding snippet defines the scaffolding of the JDBC implementation for our PersonDao interface. Once the datasource reference is injected (via setter injection), we instantiate a JdbcTemplate instance and assign it to our private jdbcTemplate member variable. JdbcPersonDao"> Notice that we are passing in the myDatasource bean that we configured earlier in this chapter. Now, when Spring creates our imageGalleryDao bean and passes in a reference to our datasource, the jdbcTemplate will be automatically created.

In an art gallery application, you’ll find domain model objects called Person, Exhibtion, Artwork and ArtCategory. The domain model objects will consist of information that’s important to it. For example, a person has a firstName and a lastName. Domain model objects can also have relationships to other domain model objects. For example, an Artwork object may have one or more ArtCategory objects that apply to it. Let’s model the Person class as follows: public class Person implements Serializable { public Integer ADMIN_ROLE_LEVEL = 1; public Integer USER_ROLE_LEVEL = 2; private Long id; private String firstName; private String lastName; private String username; private String password; private Integer roleLevel; private Integer version; public Person() { Spring Persistence: A Running Start 23 } …(Getters and setters omitted) } The DAO Layer The goal of the DAO layer is to completely abstract the datasource and ways in which it loads, saves, and manipulates the data at hand.

It’s easy to understand now how this concept will allow us to employ multiple strategies to access a datasource without tying ourselves down to a particular solution. If you use the JndiObjectFactoryBean (a factory bean for resolving JNDI datasources), you will still end up with a DataSource reference, and the same will occur if you choose to use the PooledDatasource implementation. There are other reasons to use a Factory-Bean in Spring, as well. For instance, a MapFactoryBean can be utilized to create a Java Map, entirely in your configuration file (which can be quite convenient in certain cases).

Download PDF sample

Rated 4.24 of 5 – based on 7 votes