22
33import org .jboss .logging .Logger ;
44import org .jboss .resteasy .annotations .jaxrs .PathParam ;
5- import org .seasar .doma .jdbc .criteria .Entityql ;
65
76import jakarta .enterprise .context .ApplicationScoped ;
87import jakarta .inject .Inject ;
2019import jakarta .ws .rs .core .Response ;
2120import jakarta .ws .rs .ext .ExceptionMapper ;
2221import jakarta .ws .rs .ext .Provider ;
22+ import org .seasar .doma .jdbc .criteria .QueryDsl ;
23+
2324import java .util .List ;
2425
2526@ Path ("fruits" )
@@ -30,19 +31,20 @@ public class FruitResource {
3031
3132 private static final Logger LOGGER = Logger .getLogger (FruitResource .class .getName ());
3233
33- @ Inject Entityql entityql ;
34+ @ Inject
35+ QueryDsl queryDsl ;
3436
3537 @ GET
3638 public List <Fruit > get () {
3739 var f = new Fruit_ ();
38- return entityql .from (f ).orderBy (c -> c .asc (f .name )).fetch ();
40+ return queryDsl .from (f ).orderBy (c -> c .asc (f .name )).fetch ();
3941 }
4042
4143 @ GET
4244 @ Path ("{id}" )
4345 public Fruit getSingle (@ PathParam Integer id ) {
4446 var f = new Fruit_ ();
45- Fruit entity = entityql .from (f ).where (c -> c .eq (f .id , id )).fetchOne ();
47+ Fruit entity = queryDsl .from (f ).where (c -> c .eq (f .id , id )).fetchOne ();
4648 if (entity == null ) {
4749 throw new WebApplicationException ("Fruit with id of " + id + " does not exist." , 404 );
4850 }
@@ -57,7 +59,7 @@ public Response create(Fruit fruit) {
5759 }
5860
5961 var f = new Fruit_ ();
60- entityql .insert (f , fruit ).execute ();
62+ queryDsl .insert (f ). single ( fruit ).execute ();
6163 return Response .ok (fruit ).status (201 ).build ();
6264 }
6365
@@ -70,14 +72,14 @@ public Fruit update(@PathParam Integer id, Fruit fruit) {
7072 }
7173
7274 var f = new Fruit_ ();
73- Fruit entity = entityql .from (f ).where (c -> c .eq (f .id , id )).fetchOne ();
75+ Fruit entity = queryDsl .from (f ).where (c -> c .eq (f .id , id )).fetchOne ();
7476
7577 if (entity == null ) {
7678 throw new WebApplicationException ("Fruit with id of " + id + " does not exist." , 404 );
7779 }
7880
7981 entity .setName (fruit .getName ());
80- entityql .update (f , entity ).execute ();
82+ queryDsl .update (f ). single ( entity ).execute ();
8183
8284 return entity ;
8385 }
@@ -87,11 +89,11 @@ public Fruit update(@PathParam Integer id, Fruit fruit) {
8789 @ Transactional
8890 public Response delete (@ PathParam Integer id ) {
8991 var f = new Fruit_ ();
90- Fruit entity = entityql .from (f ).where (c -> c .eq (f .id , id )).fetchOne ();
92+ Fruit entity = queryDsl .from (f ).where (c -> c .eq (f .id , id )).fetchOne ();
9193 if (entity == null ) {
9294 throw new WebApplicationException ("Fruit with id of " + id + " does not exist." , 404 );
9395 }
94- entityql .delete (f , entity ).execute ();
96+ queryDsl .delete (f ). single ( entity ).execute ();
9597 return Response .status (204 ).build ();
9698 }
9799
0 commit comments