Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion frameworks/Java/spring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ This is the Spring MVC portion of a [benchmarking test suite](../) comparing a v

An embedded undertow is used for the web server.

There are three implementations :
There are four implementations :
* For postgresql access, JdbcTemplate is used. See [JdbcDbRepository](src/main/java/hello/JdbcDbRepository.java).
* For postgresql access, Spring Data JDBC is used. See [DataJdbcDbRepository](src/main/java/hello/DataJdbcDbRepository.java).
* For postgresql access, jOOQ is used. See [JooqDbRepository](src/main/java/hello/JooqDbRepository.java).
* For mongoDB access, MongoTemplate is used. See [MongoDbRepository](src/main/java/hello/MongoDbRepository.java).

### Plaintext Test
Expand Down Expand Up @@ -63,3 +64,19 @@ There are three implementations :
### Template rendering Test

http://localhost:8080/fortunes

## Build

### jOOQ

The jOOQ version requires Java classes generated from the database schema into
`src/main/jooq/hello/db`. In order to generate them, you need to run a postgresql container and
then execute the Maven `jooq-codegen:generate` command:

```bash
(../../../toolset/databases/postgres && docker run -p 5432:5432 --rm "$(docker build -q -f postgres.dockerfile .)")
```

```bash
mvn jooq-codegen:generate
```
23 changes: 23 additions & 0 deletions frameworks/Java/spring/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@
"notes": "",
"versus": ""
},
"jooq": {
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries?queries=",
"fortune_url": "/fortunes",
"plaintext_url": "/plaintext",
"update_url": "/updates?queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "Postgres",
"framework": "spring",
"language": "Java",
"flavor": "None",
"orm": "Full",
"platform": "Servlet",
"webserver": "Undertow",
"os": "Linux",
"database_os": "Linux",
"display_name": "spring-jooq",
"notes": "",
"versus": ""
},
"mongo": {
"db_url": "/db",
"query_url": "/queries?queries=",
Expand Down
56 changes: 56 additions & 0 deletions frameworks/Java/spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
Expand Down Expand Up @@ -84,6 +88,58 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>

<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
</dependencies>

<configuration>
<jdbc>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/hello_world</url>
<user>benchmarkdbuser</user>
<password>benchmarkdbpass</password>
</jdbc>
<generator>
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<includes>.*</includes>
<excludes>pg_stat.*</excludes>
<inputSchema>public</inputSchema>
</database>
<target>
<packageName>hello.db</packageName>
<directory>src/main/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>add-jooq-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/jooq</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions frameworks/Java/spring/spring-jooq.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM maven:3.9.5-eclipse-temurin-21 AS maven
WORKDIR /spring
COPY src src
COPY pom.xml pom.xml
RUN mvn package -q

FROM bellsoft/liberica-openjre-debian:23
WORKDIR /spring
COPY --from=maven /spring/target/hello-spring-1.0-SNAPSHOT.jar app.jar
# See https://docs.spring.io/spring-boot/reference/packaging/efficient.html
RUN java -Djarmode=tools -jar app.jar extract

EXPOSE 8080

CMD ["java", "-XX:+DisableExplicitGC", "-XX:+UseStringDeduplication", "-Dlogging.level.root=OFF", "-jar", "app/app.jar", "--spring.profiles.active=jooq"]
13 changes: 13 additions & 0 deletions frameworks/Java/spring/src/main/java/hello/JooqConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package hello;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Profile("jooq")
@Configuration
@EnableAutoConfiguration(exclude = { JdbcRepositoriesAutoConfiguration.class })
public class JooqConfig {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package hello.repository;

import static hello.db.tables.Fortune.FORTUNE;
import static hello.db.tables.World.WORLD;

import java.util.List;

import org.jooq.DSLContext;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Repository;

import hello.db.tables.records.WorldRecord;
import hello.model.Fortune;
import hello.model.World;

@Repository
@Profile("jooq")
public class JooqDbRepository implements DbRepository {

private DSLContext dslContext;

public JooqDbRepository(DSLContext dslContext) {
this.dslContext = dslContext;
}

@Override
public World getWorld(int id) {
return dslContext.selectFrom(WORLD).where(WORLD.ID.eq(id)).fetchOneInto(World.class);
}

@Override
public void updateWorlds(List<World> worlds) {
dslContext.batchUpdate(worlds.stream().map(it -> new WorldRecord(it.id, it.randomNumber)).toList()).execute();
}

@Override
public List<Fortune> fortunes() {
return dslContext.selectFrom(FORTUNE).fetchInto(Fortune.class);
}

}
54 changes: 54 additions & 0 deletions frameworks/Java/spring/src/main/jooq/hello/db/DefaultCatalog.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions frameworks/Java/spring/src/main/jooq/hello/db/Keys.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions frameworks/Java/spring/src/main/jooq/hello/db/Public.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions frameworks/Java/spring/src/main/jooq/hello/db/Tables.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading