java - Spring, Morphia and DataAccessException implementation -
i'm using morphia , mongodb spring application. see in many of example projects many of service interface methods throw dataaccessexception. can tell, exception thrown various framework classes simplify exception handling various implementations of data access.
at point i'm guessing should catch errors thrown morphia , throw dataaccessexception service implementation. question is, should model approach service implementations use morphia? or perhaps i'm misunderstanding this.
this makes sense if want business logic able react specific types of dataaccessexception
, without being dependent on morphia/mongo types.
the easiest way write class implements persistenceexceptiontranslator
, , knows how translate morphia/mongo exceptions dataaccessexception
. declare class bean, , spring automatically ask translate exceptions if dao class annotated @repository
.
however, if business logic or exception-handling logic doesn't care which exception type thrown, there seem little point.
Comments
Post a Comment