Skip to content

Commit 7b33d6e

Browse files
authored
Merge pull request #48 from jenetics/releases/r2.1.0
#r2.1.0
2 parents 82d0385 + 1389f8e commit 7b33d6e

31 files changed

+502
-119
lines changed

README.md

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _Making the JDBC usage simpler and less verbose._
1010

1111
## Overview
1212

13-
JDBC is the basic API for accessing relational databases. Being basic makes it quite tedious to use directly. This lead to higher level abstractions like [JPA](https://docs.oracle.com/javaee/7/tutorial/partpersist.htm). Using a full-grown _Object Relational Mapper_ on the other side might be to heavy weight for many uses cases. _FacileJDBC_ tries to fill the gap by making the low level JDBC access less verbose and tedious. SQL is still used as query language.
13+
JDBC is the basic API for accessing relational databases. Being basic makes it quite tedious to use directly. This leads to higher level abstractions like [JPA](https://docs.oracle.com/javaee/7/tutorial/partpersist.htm). Using a full-grown _Object Relational Mapper_ on the other side might be to heavy weight for many uses cases. _FacileJDBC_ tries to fill the gap by making the low-level JDBC access less verbose and tedious. SQL is still used as a query language.
1414

1515
> The API of this library has been heavily influenced by the Scala [Anorm](https://playframework.github.io/anorm/) library.
1616
@@ -470,7 +470,7 @@ final Transactional db = ds::getConnection;
470470

471471
The library is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
472472

473-
Copyright 2019-2021 Franz Wilhelmstötter
473+
Copyright 2019-2023 Franz Wilhelmstötter
474474

475475
Licensed under the Apache License, Version 2.0 (the "License");
476476
you may not use this file except in compliance with the License.
@@ -486,44 +486,32 @@ The library is licensed under the [Apache License, Version 2.0](http://www.apach
486486

487487
## Release notes
488488

489-
### [2.0.0](https://github.com/jenetics/facilejdbc/releases/tag/v2.0.0)
489+
### [2.1.0](https://github.com/jenetics/facilejdbc/releases/tag/v2.1.0)
490490

491491
#### Improvements
492492

493-
* [#21](https://github.com/jenetics/facilejdbc/issues/21): Create `Ctor` instances from Record classes. It is now possible to create `Ctor` directly from `record` classes.
493+
* [#23](https://github.com/jenetics/facilejdbc/issues/23): Implementation of `Stored` class.
494494
```java
495-
// Simple `Dctor` creation.
496-
final Dctor<Book> dctor = Dctor.of(Book.class);
495+
// Reading 'Link' objects from db.
496+
final List<Stored<Long, Link>> links = select
497+
.as(LINK_PARSER.stored("id").list(), conn);
497498

498-
// Adapt the name conversion.
499-
final Dctor<Book> dctor = Records.dctor(
500-
Book.class,
501-
component -> switch (component.getName()) {
502-
case "author" -> "primary_author";
503-
case "isbn" -> "isbn13";
504-
default -> Records.toSnakeCase(component);
505-
}
506-
);
499+
// Printing the result + its DB ids.
500+
links.forEach(System.out::println);
507501

508-
// Add additional columns.
509-
final Dctor<Book> dctor = Records.dctor(
510-
Book.class,
511-
field("title_hash", book -> book.title().hashCode())
512-
);
502+
// > Stored[id=1, value=Link[http://jenetics.io, text=null, type=null]]
503+
// > Stored[id=2, value=Link[http://jenetics.io, text=Jenetics, type=web]]
504+
// > Stored[id=3, value=Link[https://duckduckgo.com, text=DuckDuckGo, type=search]]
513505
```
514-
* [#43](https://github.com/jenetics/facilejdbc/issues/43): Create `RowParser` instances from `record` classes.
506+
* [#49](https://github.com/jenetics/facilejdbc/issues/49): Implement `PreparedQuery` class.
515507
```java
516-
// Simple `RowParser` creation.
517-
final RowParser<Book> parser = RowParser.of(Book.class);
518-
519-
// Adapting the record component parsing.
520-
final RowParser<Book> parser = Records.parserWithFields(
521-
Book.class,
522-
Map.of(
523-
"isbn", string("isbn").map(Isbn::new),
524-
"authors", int64("id").map(Author::selectByBookId)
525-
)
526-
);
508+
final var query = INSERT_LINK.prepareQuery(conn);
509+
final var batch = Batch.of(links, LINK_DCTOR);
510+
query.execute(batch);
527511
```
528512

513+
#### Bug
514+
515+
* [#23](https://github.com/jenetics/facilejdbc/issues/23): Remove wrong `null` check in `Param` factory method.
516+
529517
_[All Release Notes](RELEASE_NOTES.md)_

RELEASE_NOTES.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
## Release notes
22

3+
### [2.1.0](https://github.com/jenetics/facilejdbc/releases/tag/v2.1.0)
4+
5+
#### Improvements
6+
7+
* [#23](https://github.com/jenetics/facilejdbc/issues/23): Implementation of `Stored` class.
8+
```java
9+
// Reading 'Link' objects from db.
10+
final List<Stored<Long, Link>> links = select
11+
.as(LINK_PARSER.stored("id").list(), conn);
12+
13+
// Printing the result + its DB ids.
14+
links.forEach(System.out::println);
15+
16+
// > Stored[id=1, value=Link[http://jenetics.io, text=null, type=null]]
17+
// > Stored[id=2, value=Link[http://jenetics.io, text=Jenetics, type=web]]
18+
// > Stored[id=3, value=Link[https://duckduckgo.com, text=DuckDuckGo, type=search]]
19+
```
20+
* [#49](https://github.com/jenetics/facilejdbc/issues/49): Implement `PreparedQuery` class.
21+
```java
22+
final var query = INSERT_LINK.prepareQuery(conn);
23+
final var batch = Batch.of(links, LINK_DCTOR);
24+
query.execute(batch);
25+
```
26+
27+
#### Bug
28+
29+
* [#23](https://github.com/jenetics/facilejdbc/issues/23): Remove wrong `null` check in `Param` factory method.
30+
331
### [2.0.0](https://github.com/jenetics/facilejdbc/releases/tag/v2.0.0)
432

533
#### Improvements

build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
plugins {
2929
base
30-
id("me.champeau.jmh") version "0.6.6" apply false
30+
alias(libs.plugins.jmh)
3131
}
3232

3333
rootProject.version = FacileJDBC.VERSION
3434

3535
tasks.named<Wrapper>("wrapper") {
36-
version = "7.3"
36+
version = "8.4"
3737
distributionType = Wrapper.DistributionType.ALL
3838
}
3939

@@ -74,6 +74,10 @@ gradle.projectsEvaluated {
7474
targetCompatibility = JavaVersion.VERSION_17
7575
}
7676

77+
configure<JavaPluginExtension> {
78+
modularity.inferModulePath.set(true)
79+
}
80+
7781
setupJava(project)
7882
setupTestReporting(project)
7983
setupJavadoc(project)
@@ -127,7 +131,7 @@ fun setupTestReporting(project: Project) {
127131
project.apply(plugin = "jacoco")
128132

129133
project.configure<JacocoPluginExtension> {
130-
toolVersion = "0.8.7"
134+
toolVersion = "0.8.11"
131135
}
132136

133137
project.tasks {

buildSrc/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13
/*
24
* Facile JDBC Library (@__identifier__@).
35
* Copyright (c) @__year__@ Franz Wilhelmstötter
@@ -34,6 +36,10 @@ repositories {
3436
gradlePluginPortal()
3537
}
3638

39+
tasks.withType<KotlinCompile>().configureEach {
40+
kotlinOptions.jvmTarget = "17"
41+
}
42+
3743
configure<JavaPluginExtension> {
3844
sourceCompatibility = JavaVersion.VERSION_17
3945
targetCompatibility = JavaVersion.VERSION_17

buildSrc/src/main/kotlin/Env.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object Env {
5252
* Information about the library and author.
5353
*/
5454
object FacileJDBC {
55-
const val VERSION = "2.0.0"
55+
const val VERSION = "2.1.0"
5656
const val ID = "facilejdbc"
5757
const val NAME = "facilejdbc"
5858
const val GROUP = "io.jenetics"

facilejdbc/src/main/java/io/jenetics/facilejdbc/Batch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/**
3131
* Represents a whole batch of query parameter values. A <em>batch</em> is
3232
* essentially an {@link Iterable} of records or row-creation functions. The
33-
* available factory functions makes it easy to create a batch from a given
33+
* available factory functions make it easy to create a batch from a given
3434
* list of records or parameters.
3535
*
3636
* <pre>{@code

facilejdbc/src/main/java/io/jenetics/facilejdbc/CSV.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.util.Arrays;
2626

2727
/**
28-
* Helper class for exporting DB result to CSV string.
28+
* Helper class for exporting a DB result to CSV string.
2929
*
3030
* @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
3131
* @version 1.3

facilejdbc/src/main/java/io/jenetics/facilejdbc/Param.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* This is the base interface of the {@link SingleParam} and {@link MultiParam}
3434
* class.
3535
* <p>
36-
* Creating single valued parameters:
36+
* Creating single-valued parameters:
3737
* <pre>{@code
3838
* INSERT_QUERY.on(
3939
* Param.value("forename", "Werner"),
@@ -84,7 +84,6 @@ public sealed interface Param permits SingleParam, MultiParam {
8484
* {@code null}
8585
*/
8686
static SingleParam value(final String name, final Object value) {
87-
requireNonNull(value);
8887
return SingleParam.of(
8988
name,
9089
(idx, stmt) -> stmt.setObject(idx, map(value))

facilejdbc/src/main/java/io/jenetics/facilejdbc/ParamValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.sql.SQLException;
2424

2525
/**
26-
* Represents a SQL value which can be set to a prepared statement. Instead of
26+
* Represents an SQL value which can be set to a prepared statement. Instead of
2727
* representing the parameter value directly, a value is defined by it's
2828
* <em>insertion</em> strategy.
2929
*

facilejdbc/src/main/java/io/jenetics/facilejdbc/ParamValues.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface ParamValues {
4545
ParamValues EMPTY = (params, stmt) -> {};
4646

4747
/**
48-
* Fills the parameters of the given statement.
48+
* Fills the parameters with the given statement.
4949
*
5050
* @param paramNames the list of parameter names which should be set, if
5151
* available by this {@code ParamValues} object. The list of parameter
@@ -60,8 +60,8 @@ void set(final List<String> paramNames, final PreparedStatement stmt)
6060
/**
6161
* Returns a composed {@code SqlParamValues} that performs, in sequence,
6262
* {@code this} operation followed by the {@code after} operation. If
63-
* performing either operation throws an exception, it is relayed to the
64-
* caller of the composed operation. If performing this operation throws an
63+
* performing either operation, throws an exception, it is relayed to the
64+
* caller of the composed operation. If performing this operation, throws an
6565
* exception, the after operation will not be performed.
6666
*
6767
* @param after the preparer to perform after {@code this} preparer

0 commit comments

Comments
 (0)