This project demonstrates the active record pattern with quarkus, panache and the ORM hibernate provider within quarkus. It relies on a postgres sql database and presents a shopping cart with products.
This project uses Quarkus, the Supersonic Subatomic Java Framework.
It demonstrates lazy fetch association patterns with the mutiny fetch, ofcourse this isn’t necessary if you fetch the association eagerly.
This project is presented in the following article
docker run -d --rm --name my_reative_db -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=my_db -p 5432:5432 postgres:10.5
curl-s -X POST "http://localhost:8080/v1/carts" -H "Content-Type: application/json" -d '{"name":"myCart"}'
curl -i -X POST "http://localhost:8080/v1/products" -H "Content-Type: application/json" -d '{"title":"product_title","description":"product_description"}'
curl -i -X GET "http://localhost:8080/v1/products"
curl -s -X PUT "http://localhost:8080/v1/carts/1/1"
curl -s -X DELETE "http://localhost:8080/v1/carts/1/1"
curl -i -X GET "http://localhost:8080/v1/carts"
curl -i -X GET "http://localhost:8080/v1/carts/1"
mvn clean install -Dquarkus.container-image.build=true -Dmaven.test.skip
docker run --net=host -it --rm --name tic_toc -p 8080:8080 <name>/reactive-rest-hibernate:1.1.0
docker rm $(docker ps -a -q) -f
docker volume prune
Located at http://localhost:8080
./mvnw package -Pnative -Dquarkus.native.container-build=true
[
{
"cartItems": [
{
"product": {
"createdAt": "2021-05-31T06:11:14Z",
"description": "description",
"id": 2,
"title": "Product2",
"updatedAt": "2021-05-31T06:11:14Z"
},
"quantity": 1
},
{
"product": {
"createdAt": "2021-05-31T06:11:14Z",
"description": "description",
"id": 1,
"title": "Product1",
"updatedAt": "2021-05-31T06:11:14Z"
},
"quantity": 2
}
],
"cartTotal": 3,
"id": 1,
"name": "MyCart"
},
{
"cartItems": [
{
"product": {
"createdAt": "2021-05-31T06:11:14Z",
"description": "description",
"id": 2,
"title": "Product2",
"updatedAt": "2021-05-31T06:11:14Z"
},
"quantity": 1
},
{
"product": {
"createdAt": "2021-05-31T06:11:14Z",
"description": "description",
"id": 1,
"title": "Product1",
"updatedAt": "2021-05-31T06:11:14Z"
},
"quantity": 2
}
],
"cartTotal": 3,
"id": 1,
"name": "MyCart"
},
{
"cartItems": [],
"cartTotal": 0,
"id": 2,
"name": "myCart"
}
]