Releases: jenetics/facilejdbc
Releases · jenetics/facilejdbc
v2.1.0
2.1.0
Improvements
- #23: Implementation of
Stored
class.
// Reading 'Link' objects from db.
final List<Stored<Long, Link>> links = select
.as(LINK_PARSER.stored("id").list(), conn);
// Printing the result + its DB ids.
links.forEach(System.out::println);
// > Stored[id=1, value=Link[http://jenetics.io, text=null, type=null]]
// > Stored[id=2, value=Link[http://jenetics.io, text=Jenetics, type=web]]
// > Stored[id=3, value=Link[https://duckduckgo.com, text=DuckDuckGo, type=search]]
- #49: Implement
PreparedQuery
class.
final var query = INSERT_LINK.prepareQuery(conn);
final var batch = Batch.of(links, LINK_DCTOR);
query.execute(batch);
Bug
- #23: Remove wrong
null
check inParam
factory method.
v2.0.0
2.0.0
Improvements
- #21: Create
Ctor
instances from Record classes. It is now possible to createCtor
directly fromrecord
classes.
// Simple `Dctor` creation.
final Dctor<Book> dctor = Dctor.of(Book.class);
// Adapt the name conversion.
final Dctor<Book> dctor = Records.dctor(
Book.class,
component -> switch (component.getName()) {
case "author" -> "primary_author";
case "isbn" -> "isbn13";
default -> Records.toSnakeCase(component);
}
);
// Add additional columns.
final Dctor<Book> dctor = Records.dctor(
Book.class,
field("title_hash", book -> book.title().hashCode())
);
- #43: Create
RowParser
instances fromrecord
classes.
// Simple `RowParser` creation.
final RowParser<Book> parser = RowParser.of(Book.class);
// Adapting the record component parsing.
final RowParser<Book> parser = Records.parserWithFields(
Book.class,
Map.of(
"isbn", string("isbn").map(Isbn::new),
"authors", int64("id").map(Author::selectByBookId)
)
);
v1.3.0
1.3.0
final var select = Query.of("SELECT * FROM person;");
// Make sure to close the returned stream.
try (var persons = select.as(PARSER.stream(), conn)) {
// Do some processing with the person stream.
persons.forEach(person -> ...);
}
- #39: Parser for exporting results as CSV file/string.
final var select = Query.of("SELECT * FROM book;");
final var csv = select.as(ResultSetParser.csvLine(), conn);
System.out.println(csv);
- #26: Implement multi-value parameter
final List<Book> results = Query.of("SELECT * FROM book WHERE id IN(:ids);")
.on(Param.values("ids", 1, 2, 3, 4))
.as(PARSER.list(), conn);
v1.2.0
v1.1.0
Improvements
final Transactional db = () -> DriverManager.getConnection(
"jdbc:hsqldb:mem:testdb",
"SA",
""
);
db.transaction().accept(conn -> {
for (var query : queries) {
query.execute(conn);
}
});
final long id = db.transaction().apply(conn ->
Book.insert(BOOKS.get(0), conn)
);
- #19: The original SQL string is reconstructible from the query object;
Query.rawSql()
.