JPA Added to Spring Data GitHub App v0.0.4

My Spring-Data app on GitHub is now at v0.0.4 with the addition of Spring Data JPA.¬†What’s interesting about v0.0.4, other than the additional of Spring Data JPA is that Hibernate services remain in place, with two separate Transaction Managers. My next blog post will cover the configuration details.

For anyone who has been following this app, I changed the repository name from Spring-Hibernate to Spring-Data since I plan on focusing more on JPA going forward. And because I plan to demonstrate JPA with a variety of back-end data sources like MongoDB and Solr I am going to simplify design of the repository by breaking out each data source by project. It was interesting to support multiple Transaction Managers in this version, for instance, but it only muddies-up design and adds needless complications.

Here you see the layout of v0.0.4 with both Spring JPA and Hibernate in play. The Hibernate and JPA have separate repositories/DAOs and services but share the same Models.

Here is the v0.0.4 Launcher which grabs the beans and injects them into a separate class for generating the output.

public class Launcher {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(SpringHbnConfiguration.class);
        ctx.register(SpringJpaConfiguration.class);
        ctx.refresh();

        ContactService contactService = 
                (ContactService) ctx.getBean("hbnContactService");
        ContactJpaService contactJpaService = 
                (ContactJpaService) ctx.getBean("jpaContactService");

        SpringProperties springProperties = ctx.getBean(SpringProperties.class);

        SpringDevelopment springDevelopment = new
                SpringDevelopment(springProperties, contactJpaService, contactService);

        springDevelopment.propertiesDemo();
        springDevelopment.hibernateDemo();
        springDevelopment.jpaDemo();

    }

}

Finally, here is the output of the new Spring JPA data retrieval samples.

As I said, next up is detailing how to configure Spring to support two separate Transaction Managers.