Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update demo to latest dependencies #162

Merged
merged 5 commits into from
Jul 11, 2023
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
6 changes: 6 additions & 0 deletions hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<artifactId>hibernate-core</artifactId>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.speedment.jpastreamer.demo.hibernate.model.Film;
import com.speedment.jpastreamer.demo.hibernate.model.Film$;

import java.util.List;
import java.util.stream.Collectors;

import static com.speedment.jpastreamer.field.predicate.Inclusion.START_INCLUSIVE_END_EXCLUSIVE;

/** This example shows how to select films that are between 100 and 120 minutes long. */
Expand All @@ -13,7 +16,7 @@ public class SimpleDemo1 {
public static void main(String[] args) {

JPAStreamer jpaStreamer = JPAStreamer.of("sakila");

System.out.println("These are the films that are of length between 100 and 120 minutes:");

jpaStreamer.stream(Film.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.speedment.jpastreamer.demo.hibernate.model;

import com.speedment.jpastreamer.demo.hibernate.model.groups.GroupA;
import com.speedment.jpastreamer.demo.hibernate.model.groups.GroupB;
import jakarta.persistence.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -28,6 +34,8 @@ public Film(Integer filmId, String title) {
private Integer filmId;

@Column(name = "title", nullable = false, columnDefinition = "varchar(255)")
@NotEmpty(message = "Title may not be empty", groups = {GroupA.class, GroupB.class})
@NotNull(message = "Title may not be null", groups = {GroupA.class, GroupB.class})
private String title;

@Column(name = "description", nullable = false, columnDefinition = "text")
Expand Down Expand Up @@ -55,6 +63,10 @@ public Film(Integer filmId, String title) {
private Float rentalRate;

@Column(name = "length", columnDefinition = "smallint(5)")
@NotEmpty(message = "Length may not be empty", groups = {GroupA.class, GroupB.class})
@NotEmpty(message = "Length may not be empty", groups = {GroupA.class})
@NotNull(message = "Length may not be null", groups = {GroupA.class, GroupB.class})
@Size(min = 1, max = 300, message = "Length must be between 1 and 300 minutes characters long")
private Integer length;

@Column(name = "replacement_cost", columnDefinition = "decimal(5,2)")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.speedment.jpastreamer.demo.hibernate.model.groups;

public interface GroupA {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package com.speedment.jpastreamer.demo.hibernate.model.groups;public interface GroupB {
}
22 changes: 6 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<spring-boot-version>3.1.0</spring-boot-version>
<jpa-streamer-version>3.0.1</jpa-streamer-version>
<jpa-streamer-version>3.0.3</jpa-streamer-version>

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand All @@ -24,7 +24,8 @@
<modules>
<module>hibernate</module>
<module>spring</module>
<module>quarkus</module>
<module>quarkus-hibernate-panache</module>
<module>quarkus-hibernate</module>
</modules>

<dependencyManagement>
Expand Down Expand Up @@ -56,18 +57,6 @@
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot-version}</version>
</dependency>

<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
Expand Down Expand Up @@ -127,9 +116,10 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

</plugins>
</pluginManagement>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 11 additions & 22 deletions quarkus/pom.xml → quarkus-hibernate-panache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jpastreamer.quarkus.demo</groupId>
<artifactId>quarkus</artifactId>
<artifactId>quarkus-hibernate-panache</artifactId>
<version>1.0-SNAPSHOT</version>

<name>quarkus-hibernate-panache</name>

<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.1.0.Final</quarkus.platform.version>
<quarkus.platform.version>3.2.0.Final</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.0.0</surefire-plugin.version>
</properties>
Expand All @@ -34,7 +37,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-rest-data-panache</artifactId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -49,31 +52,17 @@
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkiverse.jpastreamer</groupId>
<artifactId>quarkus-jpastreamer</artifactId>
<version>3.0.1.Alpha3</version>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<proc>only</proc>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.speedment.jpastreamer.demo.quarkus.model.Film;
import com.speedment.jpastreamer.demo.quarkus.repository.FilmRepository;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
Expand All @@ -12,23 +11,21 @@
import java.util.stream.Collectors;

@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class FilmResource {

@Inject
FilmRepository filmRepository;

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/list/{limit}")
@Path("list/{limit}")
public String list(int limit) {
return filmRepository.listFilms(limit).map(Film::getTitle).collect(Collectors.joining("\n"));
}

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/sorted/{limit}")
@Path("sorted/{limit}")
public String sorted(int limit) {
return filmRepository.listFilmsSortedByRatingAndLength(limit)
.map(f -> String.format("%s (%s): %s min\n", f.getTitle(), f.getRating(), f.getLength()))
Expand All @@ -37,7 +34,7 @@ public String sorted(int limit) {

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/paging/{page}")
@Path("paging/{page}")
public String paging(int page) {
return filmRepository.paging(page)
.map(f -> String.format("%s: %s min\n", f.getTitle(), f.getLength()))
Expand All @@ -46,7 +43,7 @@ public String paging(int page) {

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/startsWithSort/{start}/{limit}")
@Path("startsWithSort/{start}/{limit}")
public String startsWithSort(String start, int limit) {
return filmRepository.titleStartsWithSortedByLengthLimited(start, limit)
.map(f -> String.format("%s: %s min\n", f.getTitle(), f.getLength()))
Expand All @@ -55,7 +52,7 @@ public String startsWithSort(String start, int limit) {

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/update/{desc}/{length}")
@Path("update/{desc}/{length}")
public String update(String desc, int length) {
// Update descriptions for films longer than "length"
filmRepository.updateDescription(desc, (short) length);
Expand All @@ -68,7 +65,7 @@ public String update(String desc, int length) {

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/actors/{start}")
@Path("actors/{start}")
public String listActors( String start) {
final StringBuilder sb = new StringBuilder();
return filmRepository.getCast(start)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.speedment.jpastreamer.streamconfiguration.StreamConfiguration;
import io.quarkus.hibernate.orm.panache.PanacheRepository;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;

import java.util.Map;
Expand All @@ -17,10 +18,12 @@

@ApplicationScoped
public class FilmRepository implements PanacheRepository<Film> {

@Inject
JPAStreamer jpaStreamer;

private final static int PAGE_SIZE = 20;
private final JPAStreamer jpaStreamer = JPAStreamer.of(this::getEntityManager);


/**
* Lists limit number of films
*
Expand Down
5 changes: 5 additions & 0 deletions quarkus-hibernate/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
43 changes: 43 additions & 0 deletions quarkus-hibernate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.flattened-pom.xml

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env

# Plugin directory
/.quarkus/cli/plugins/
1 change: 1 addition & 0 deletions quarkus-hibernate/.mvn/wrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven-wrapper.jar
Loading
Loading