From eee708c15c0274eacd8da2aee021cdca96cabda2 Mon Sep 17 00:00:00 2001 From: orekyuu Date: Sun, 17 Nov 2024 21:32:01 +0900 Subject: [PATCH] Replace to QueryDsl. --- gradle.properties | 6 +++--- pom.xml | 8 ++++---- src/main/java/sample/FruitResource.java | 20 +++++++++++--------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2204fdc..e9e1457 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=org.seasar.doma version=1.0 -quarkusVersion=3.15.1 -quarkusDomaVersion=0.0.10 -domaVersion=3.0.1 +quarkusVersion=3.16.3 +quarkusDomaVersion=0.0.12 +domaVersion=3.1.0 diff --git a/pom.xml b/pom.xml index e6a4568..3dd1524 100644 --- a/pom.xml +++ b/pom.xml @@ -8,12 +8,12 @@ 1.0 - 3.15.1 + 3.16.3 quarkus-bom io.quarkus - 3.15.1 - 0.0.10 - 3.0.1 + 3.16.3 + 0.0.12 + 3.1.0 3.5.0 3.13.0 0.28.0 diff --git a/src/main/java/sample/FruitResource.java b/src/main/java/sample/FruitResource.java index 34c48dd..fe32b60 100644 --- a/src/main/java/sample/FruitResource.java +++ b/src/main/java/sample/FruitResource.java @@ -2,7 +2,6 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.jaxrs.PathParam; -import org.seasar.doma.jdbc.criteria.Entityql; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -20,6 +19,8 @@ import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.Provider; +import org.seasar.doma.jdbc.criteria.QueryDsl; + import java.util.List; @Path("fruits") @@ -30,19 +31,20 @@ public class FruitResource { private static final Logger LOGGER = Logger.getLogger(FruitResource.class.getName()); - @Inject Entityql entityql; + @Inject + QueryDsl queryDsl; @GET public List get() { var f = new Fruit_(); - return entityql.from(f).orderBy(c -> c.asc(f.name)).fetch(); + return queryDsl.from(f).orderBy(c -> c.asc(f.name)).fetch(); } @GET @Path("{id}") public Fruit getSingle(@PathParam Integer id) { var f = new Fruit_(); - Fruit entity = entityql.from(f).where(c -> c.eq(f.id, id)).fetchOne(); + Fruit entity = queryDsl.from(f).where(c -> c.eq(f.id, id)).fetchOne(); if (entity == null) { throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404); } @@ -57,7 +59,7 @@ public Response create(Fruit fruit) { } var f = new Fruit_(); - entityql.insert(f, fruit).execute(); + queryDsl.insert(f).single(fruit).execute(); return Response.ok(fruit).status(201).build(); } @@ -70,14 +72,14 @@ public Fruit update(@PathParam Integer id, Fruit fruit) { } var f = new Fruit_(); - Fruit entity = entityql.from(f).where(c -> c.eq(f.id, id)).fetchOne(); + Fruit entity = queryDsl.from(f).where(c -> c.eq(f.id, id)).fetchOne(); if (entity == null) { throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404); } entity.setName(fruit.getName()); - entityql.update(f, entity).execute(); + queryDsl.update(f).single(entity).execute(); return entity; } @@ -87,11 +89,11 @@ public Fruit update(@PathParam Integer id, Fruit fruit) { @Transactional public Response delete(@PathParam Integer id) { var f = new Fruit_(); - Fruit entity = entityql.from(f).where(c -> c.eq(f.id, id)).fetchOne(); + Fruit entity = queryDsl.from(f).where(c -> c.eq(f.id, id)).fetchOne(); if (entity == null) { throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404); } - entityql.delete(f, entity).execute(); + queryDsl.delete(f).single(entity).execute(); return Response.status(204).build(); }