Skip to content

quarkiverse/quarkus-jdbi

Repository files navigation

quarkus-jdbi

Build License Central

All Contributors

Jdbi provides convenient, idiomatic access to relational data in Java This quarkus extension makes it possible to use JDBI in native executables.

Versioning

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.

Example usage

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());
    }
}

Authors

Original repo: https://github.com/famartinrh/jdbi-quarkus-extension

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Tamas
Tamas

💻 🚧
Andreas Maechler
Andreas Maechler

🚧
Joost den Boer
Joost den Boer

💻
Phin Jensen
Phin Jensen

💻
Guillaume Smet
Guillaume Smet

🚧
George Gastaldi
George Gastaldi

🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Jdbi provides convenient, idiomatic access to relational data in Java

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 12

Languages