A zero dependency light-weight wrapper for JDBC, using String Templates and records.
OTHER License
Bot releases are hidden (Show)
Published by hjohn 3 months ago
This allows back and forth conversions of a Java class to a database type, for example:
databaseBuilder.addTypeConverter(
LocalDateTime.class,
TypeConverter.of(Timestamp.class, Timestamp::valueOf, Timestamp::toLocalDateTime)
);
database.accept(tx ->
tx."INSERT INTO company (\{ALL}) VALUES (\{ALL.batch(companies)})".execute()
);
record
s), for easier custom types: Reflector.ofClass(MyBean.class);
Reflector<Coordinate> reflector = Reflector.custom(
Coordinate.class,
row -> new Coordinate(row.getInt(0), row.getInt(1)),
List.of(
Mapping.of("x", int.class, Coordinate::x),
Mapping.of("y", int.class, Coordinate::y)
)
);
record
sub-type has been made explicit, and can now be fully controlled for all types (not just records):Given:
record Coordinate(int x, int y) {}
record Trip(Coordinate start, Coordinate end) {}
Then:
Reflector.of(Trip.class)
.nest("start", Reflector.of(Coordinate.class))
.nest("end", Reflector.of(Coordinate.class));
Will create a Reflector
for Trip
with the fields start_x
, start_y
, end_x
and end_y
.
The prefixing behavior can be controlled by using either Reflector::inline
or Reflector::nest
and using the new Reflector::prefix
method.
Published by hjohn 8 months ago
Database
and CheckedDatabase
to interfacesMockDatabase
implement Database
MockCheckedDatabase
which implements CheckedDatabase
Published by hjohn 8 months ago
MockDatabase
to make testing easierRow
no longer throws SQLException
when using itConnection
until a statement needs to be executedPublished by hjohn 8 months ago
Published by hjohn 8 months ago
get
and toOptional
methods fail if there is more than one resultgetFirst
method that operates how get
did before (get the first result, ignoring any others)Published by hjohn 8 months ago