Create Hibernate implementation of ApplicationErrorDao in dropwizard-application-errors? #146
Closed
sleberknight
started this conversation in
Ideas
Replies: 1 comment
|
Because of the various pitfalls described above, we decided not to even try to do this. It will probably be complicated, and will not provide much benefit. Instead #248 (plain JDBC implementation of |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This would allow us to use that implementation in the services that are using Hibernate, instead of having to create a JDBI-based instance.
Considerations and possible pitfalls and road blocks:
Annotations
This could this be problematic since ApplicationError doesn't have all the JPA/Hibernate persistence annotations (and I don't want to put all those all over it)
Internal Model
Would probably need some kind of "internal" model (e.g. HibernateApplicationError) that is used by Hibernate and then we would have to transform it into regular ApplicationError objects. That would be annoying, but would probably work.
Sessions and Exceptions
This could cause other problems, aside from the issues mentioned above. Most significantly, if a Hibernate exception is thrown by persistence code, and then the Hibernate-based
ApplicationErrorDaouses the sameSession, then it will also fail since theSessionis "unsafe" at that point. We'd have to guarantee it always uses a newSession. This could be accomplished by supplying aSessionFactoryto the DAO's constructor, and always using a newSessionwhen saving application errors.As long as we guarantee a separate
Sessionit should work. We should consider using aStatelessSessionsince there is no need to cache the savedApplicationError.All reactions