Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate (JPA) - Exception Handling

Adolfo Eloy
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all.

I'm writing a service (only a POJO that implements an interface that is injected by Spring 2 in my JSF 1.2 ManagedBeans).
My service, have an EntityManaged injected by Spring via @PersistenceContext annotation (I'm not using DAOs interface).

Well, the point is: I'd like to make foundations to decide the best way to handle the EntityManager exceptions in my service.

I'm posting my code as follows and I'd like to discuss if this is a good way or there is another way that can be more efficiently.
At this example, my method saveUser throws RegistryException that is an abstract Exception related to my service that will
encapsulate low level exceptions that may occur inside it when using my entitymanager instance or when business divergences

Thanks in advance.
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!