Configuring modular JPA applications with Spring

One of the top problem with JPA configuration is the inability to provide a true modular configuration of an application’s persistence unit. The persistence unit declares the entities that are to be included for a particular JPA-compliant implementation like Hibernate. The problem in practice is that it is forbidden to link entities if they are placed in two different persistence units so a single persistence unit, defined at the application level must be used. This single configuration file needs to declare the entities and/or the list of JAR files to be scanned in the application and it needs to be aware of all the modules that are used by the application (that is, it cannot update itself based on the available modules). This blog entry explains how this issue can be circumvented using Spring. A sample showcase project is also attached. [...]

Flexible JPA configuration with Spring

The Spring framework provides great configurable options and sensitive defaulting when it comes to initialize an EntityManager. The solution is not a silver bullet though but it is open enough to extend the mechanism through post processors.

Configuring the transaction type attribute namely is not as easy as it should be. Depending on whether you [...]