• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring, JPA and Albert Einstein

 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Everything should be made as simple as possible, but not simpler." AE.

Do you agree JPA is simple enough? We don't need a template, even if it's from Spring :-)
Thank you.
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic