Now that we have introduced JPA, its role, and the benefits of using Entities, we can now focus on how to configure our Spring application to handle them.
As we said earlier, the JPA is a specification. Choosing a persistence provider (Hibernate, OpenJPA, TopLink, and so on) or a database provider for an application won't be a commitment as long as they match the standards.
We will see that our JPA configuration in Spring is done by defining two beans: datasource and entityManagerFactory. Then, the optional Spring Data JPA
library offers a JPA
repository abstraction that is able to surprisingly simplify some database operations.
From the Git Perspective in Eclipse, check out the latest version of the
v3.x.x
branch.As previously introduced, we have added a couple of beans to the Spring configuration file (in the core module)
csmcore-config.xml
:<jpa:repositories base-package="edu.zc.csm.core.daos" /> <bean id...