Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Hibernate classes in LoggingExceptionMapper #48

Closed
chrisrohr opened this issue Dec 9, 2020 · 2 comments · Fixed by #79
Closed

Handle Hibernate classes in LoggingExceptionMapper #48

chrisrohr opened this issue Dec 9, 2020 · 2 comments · Fixed by #79
Assignees
Labels
enhancement A request for change or improvement to an existing feature
Milestone

Comments

@chrisrohr
Copy link
Contributor

If we are doing this shenanigans for Spring classes, then we probably should also do it for Hibernate, especially since we removed Spring from most services that are using Hibernate and are just using Dropwizard's native Hibernate support.

However, I suggest adding a new issue to add this functionality instead of doing it here.

Originally posted by @sleberknight in #37 (comment)

@chrisrohr
Copy link
Contributor Author

@sleberknight What packages specifically do you want to handle?

@sleberknight
Copy link
Member

For now, these:

  • org.hibernate.dialect.lock.OptimisticEntityLockException
  • org.hibernate.exception.ConstraintViolationException

@sleberknight sleberknight self-assigned this Jan 8, 2021
@sleberknight sleberknight added the enhancement A request for change or improvement to an existing feature label Jan 8, 2021
@sleberknight sleberknight added this to the 0.2.0 milestone Jan 8, 2021
sleberknight added a commit that referenced this issue Jan 8, 2021
* Handle Hibernate OptimisticEntityLockException and
  ConstraintViolationException classes
* Refactor internal logic to use a map from class name to a category
  which is then used to select the appropriate response status code.
  The only annoying thing is that we don't yet have Java's new
  exhaustive compiler check on the switch, so the default arm cannot
  be covered with tests.
* Refactor LoggingExceptionMapperTest to use the actual Spring and
  Hibernate classes, which allowed us to change the
  dataAccessExceptionResponse method to be private
* Add the Spring and Hibernate dependencies with test scope

Closes #48
sleberknight added a commit that referenced this issue Jan 8, 2021
…per (#79)

* Handle select Hibernate data exception classes in LoggingExceptionMapper

* Handle Hibernate OptimisticEntityLockException and
  ConstraintViolationException classes
* Refactor internal logic to use a map from class name to a category
  which is then used to select the appropriate response status code.
  The only annoying thing is that we don't yet have Java's new
  exhaustive compiler check on the switch, so the default arm cannot
  be covered with tests.
* Refactor LoggingExceptionMapperTest to use the actual Spring and
  Hibernate classes, which allowed us to change the
  dataAccessExceptionResponse method to be private
* Add the Spring and Hibernate dependencies with test scope

Closes #48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A request for change or improvement to an existing feature
Projects
None yet
2 participants