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

Add plain JDBC ApplicationErrorDao implementation #248

Closed
sleberknight opened this issue Mar 16, 2023 · 0 comments · Fixed by #316
Closed

Add plain JDBC ApplicationErrorDao implementation #248

sleberknight opened this issue Mar 16, 2023 · 0 comments · Fixed by #316
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

A plain JDBC implementation would be useful in applications that use a relational database but don't use JDBI (e.g. maybe it uses Hibernate), and which don't want to add another dependency.

@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Mar 16, 2023
@sleberknight sleberknight self-assigned this Nov 12, 2023
@sleberknight sleberknight added this to the 2.1.0 milestone Nov 12, 2023
sleberknight added a commit that referenced this issue Nov 13, 2023
* Add JdbcApplicationErrorDao, a plain JDBC implementation of
  ApplicationErrorDao
* Since the logic to map from a ResultSet is identical for the
  JDBC and JDBI implementations, move that logic from the
  Jdbi3ApplicationErrorRowMapper into ApplicationErrorJdbc in
  a new method 'mapFrom(ResultSet)'. Also, fix how the port
  is set, using rs.getInt instead of intValueOrNull, since
  the port field in ApplicationError is an int, not Integer
* Add new constructor accepting only a Throwable to
  ApplicationErrorJdbc.ApplicationErrorJdbcException
* Add several new helper methods to ApplicationErrorJdbc
  for the JDBC implementation, nextOrThrow and shutdownH2Database
* Add abstract base test class, AbstractJdbcApplicationErrorDaoTest,
  and two subclasses for testing against H2 and Postgres
* Make sure to shut down the in-memory H2 database in both
  H2Jdbi3ApplicationErrorDaoTest and H2JdbcApplicationErrorDaoTest.
  Otherwise, if the H2 JDBI test runs after the JDBC one, the
  tests fail because they expect the database to be empty.
  By shutting the in-memory database down, we ensure the tests
  are completely isolated.

Misc:

* Remove two redundant warning suppression annotations from
  ErrorContextUtilitiesTest

Closes #248
sleberknight added a commit that referenced this issue Nov 18, 2023
* Add plain JDBC ApplicationErrorDao implementation

* Add JdbcApplicationErrorDao, a plain JDBC implementation of
  ApplicationErrorDao
* Since the logic to map from a ResultSet is identical for the
  JDBC and JDBI implementations, move that logic from the
  Jdbi3ApplicationErrorRowMapper into ApplicationErrorJdbc in
  a new method 'mapFrom(ResultSet)'. Also, fix how the port
  is set, using rs.getInt instead of intValueOrNull, since
  the port field in ApplicationError is an int, not Integer
* Add new constructor accepting only a Throwable to
  ApplicationErrorJdbc.ApplicationErrorJdbcException
* Add several new helper methods to ApplicationErrorJdbc
  for the JDBC implementation, nextOrThrow and shutdownH2Database
* Add abstract base test class, AbstractJdbcApplicationErrorDaoTest,
  and two subclasses for testing against H2 and Postgres
* Make sure to shut down the in-memory H2 database in both
  H2Jdbi3ApplicationErrorDaoTest and H2JdbcApplicationErrorDaoTest.
  Otherwise, if the H2 JDBI test runs after the JDBC one, the
  tests fail because they expect the database to be empty.
  By shutting the in-memory database down, we ensure the tests
  are completely isolated.

Misc:

* Remove two redundant warning suppression annotations from
  ErrorContextUtilitiesTest

Closes #248

* Move shutdownH2Database into a test utility class

* Implement transaction rollback in JDBC DAO tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant