Company
Date Published
Author
Jeremy Moore
Word count
1420
Language
English
Hacker News points
None

Summary

JDBI is a library that provides an improved interface over JDBC for working with SQL databases in Java, offering two different style APIs: fluent style and object style. The fluent style API is similar to the JDBC interface, while the object style API provides an idiomatic Java interface for executing queries. JDBI uses cglib, a code generation library, to create dynamic proxy objects and intercept field access. However, this can lead to issues with concurrent execution, as seen in the case of using `JdbcConnectionPool` instances concurrently. To fix this issue, it is recommended to only intercept methods on the instances created from a Factory, but due to an upstream bug, this approach was not feasible. Instead, it is suggested to avoid using the generated DAOs entirely and use jOOQ, which provides a builder interface for safely constructing SQL queries. This allows for greater flexibility in crafting queries while avoiding direct manipulation of raw SQL.