Repository navigation
Releases: hjohn/TemplatedJDBC
Releases · hjohn/TemplatedJDBC
Release list
0.1.1
0.1.0
- Modularized project
- Add support for type conversions on the database and reflector level:
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)
);- Batch support to insert multiple objects with one statement:
database.accept(tx ->
tx."INSERT INTO company (\{ALL}) VALUES (\{ALL.batch(companies)})".execute()
);- Reflector now supports bean classes (and already supported
records), for easier custom types:
Reflector.ofClass(MyBean.class);- Reflector allows fully customizing its construction to allow for unsupported types:
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)
)
); - Inlining of a
recordsub-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.
- Some backwards incompatible rearranging of types to improve the structure of the project