• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring, JPA and Albert Einstein

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic