Jdbi provides convenient, idiomatic access to relational data in Java This quarkus extension makes it possible to use JDBI in native executables.
The repo follows semver for versioning of its own API. This means the following:
-
Major version is raised only in case of breaking changes to your quarkus-jdbi usage. (When you need to adjust your code).
-
Minor version is raised only in case of functional changes to quarkus-jdbi. eg. new annotations supported etc...
-
Patch version is raised in case of bugfixes OR dependency changes (regardless whether they are breaking or not). eg. quarkus and jdbi version changes will be signalled as patch releases.
Add the following dependency in your pom.xml to get started,
<dependency>
<groupId>io.quarkiverse.jdbi</groupId>
<artifactId>quarkus-jdbi</artifactId>
</dependency>You need to inject AgroalDatasource:
public class JdbiProvider {
@Inject
AgroalDataSource ds;
@Singleton
@Produces
public Jdbi jdbi() {
Jdbi jdbi = Jdbi.create(ds);
jdbi.installPlugin(new SqlObjectPlugin());
return jdbi;
}
}and you can use it everywhere:
public class UserDAO {
@Inject
Jdbi jdbi;
public Optional<User> findUserById(long id) {
return jdbi.inTransaction(transactionHandle ->
transactionHandle.createQuery("SELECT * FROM users WHERE id=:id")
.bind("id", id)
.mapTo(User.class)
.findFirst());
}
}Original repo: https://github.com/famartinrh/jdbi-quarkus-extension
Thanks goes to these wonderful people (emoji key):
Tamas 💻 🚧 |
Andreas Maechler 🚧 |
Joost den Boer 💻 |
Phin Jensen 💻 |
Guillaume Smet 🚧 |
George Gastaldi 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!