K Mansoor wrote:Do you agree JPA is simple enough? We don't need a template, even if it's from Spring :-)
Thank you.
I'm not so sure that JPA is as simple as it could be...but yeah, it's pretty simple.
Even though Spring has a JpaTemplate, that exists for consistency's sake with the other template-based persistence options Spring offers. It's recommended practice to not use it however (or HibernateTemplate) and rely on contextual sessions instead. Effectively Spring doesn't get too involved in your JPA DAOs. You can, however, let Spring rethrow JPA-specific exceptions as one of Spring's data access exceptions, though. And you can wire up your JPA config and apply Spring-style declarative transactions when using JPA. But if you're using JpaTemplate, then
you should probably look into ditching it and go with basic JPA.
BTW, that's the approach I use in the book.