diff --git a/pom.xml b/pom.xml index d5c0935..774abb3 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.eclipse.jnosql.databases - jnosql-mongodb + jnosql-oracle-nosql ${jnosql.version} diff --git a/src/main/java/org/soujava/samples/hotel/Guest.java b/src/main/java/org/soujava/samples/hotel/Guest.java index 7f567b9..4de737b 100644 --- a/src/main/java/org/soujava/samples/hotel/Guest.java +++ b/src/main/java/org/soujava/samples/hotel/Guest.java @@ -2,7 +2,8 @@ import jakarta.nosql.Column; import jakarta.nosql.Embeddable; +import jakarta.nosql.Entity; -@Embeddable +@Entity public record Guest (@Column String documentNumber, @Column String name) { } diff --git a/src/main/java/org/soujava/samples/hotel/Hotel.java b/src/main/java/org/soujava/samples/hotel/Hotel.java index 1afef0c..b35f46a 100644 --- a/src/main/java/org/soujava/samples/hotel/Hotel.java +++ b/src/main/java/org/soujava/samples/hotel/Hotel.java @@ -21,7 +21,7 @@ public interface Hotel { void checkOut(Room room); @Find - Optional reservation(@By(org.soujava.samples.hotel._Room.NUMBER) int number); + Optional reservation(@By(org.soujava.samples.hotel._Room.NUMBER) String number); Page findBy(PageRequest pageRequest); } diff --git a/src/main/java/org/soujava/samples/hotel/HotelResource.java b/src/main/java/org/soujava/samples/hotel/HotelResource.java index a0bc902..5df9070 100644 --- a/src/main/java/org/soujava/samples/hotel/HotelResource.java +++ b/src/main/java/org/soujava/samples/hotel/HotelResource.java @@ -2,14 +2,18 @@ import jakarta.data.page.PageRequest; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.DefaultValue; import jakarta.ws.rs.GET; import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import java.util.List; @@ -17,12 +21,15 @@ @Path("/hotels") @ApplicationScoped +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) public class HotelResource { private static final Logger LOGGER = Logger.getLogger(HotelResource.class.getName()); private final Hotel hotel; + @Inject public HotelResource(Hotel hotel) { this.hotel = hotel; } @@ -43,7 +50,7 @@ public List rooms(@QueryParam("page") @DefaultValue("1") int page, @GET @Path("/{number}") - public Room reservation(@PathParam("number") int number) { + public Room reservation(@PathParam("number") String number) { LOGGER.info("Finding reservation: " + number); return hotel.reservation(number) .orElseThrow(() -> new WebApplicationException("Room not found", Response.Status.NOT_FOUND)); @@ -57,7 +64,7 @@ public Room checkIn(Room room) { @DELETE @Path("/{number}") - public void checkOut(@PathParam("number") int number) { + public void checkOut(@PathParam("number") String number) { LOGGER.info("Check out: " + number); var room = hotel.reservation(number) .orElseThrow(() -> new WebApplicationException("Room not found", Response.Status.NOT_FOUND)); diff --git a/src/main/java/org/soujava/samples/hotel/Room.java b/src/main/java/org/soujava/samples/hotel/Room.java index 2c07733..4177610 100644 --- a/src/main/java/org/soujava/samples/hotel/Room.java +++ b/src/main/java/org/soujava/samples/hotel/Room.java @@ -5,6 +5,6 @@ import jakarta.nosql.Id; @Entity -public record Room (@Id int number, @Column Guest guest) { +public record Room (@Id String number, @Column Guest guest) { }