Con mucha alegría saco mi nueva plataforma de estudios denominada aprendeconjoe.com, el cual reemplazará a campus.joedayz.pe, por ahora empezaremos con venta de cursos de forma individual a USD 9.99 cada uno. Veamos como se dan las cosas en estos meses y si tiene la acogida que esperamos.

En Septiembre 2021 tenemos los siguientes cursos pagados:

Los siguientes cursos gratuitos:

Cualquier consulta no dude en contactarme por WhatsApp al +51 939965148.




Backend of Comparabien.com.pe with JakartaEE, DeltaSpike and Blaze Persistence


In this article we are going to remember 2 previous articles that are:

Source Code

The backend source code is in this link https://github.com/joedayz/ConcentradorJakartaEE.
The frontend source code is in this link https://github.com/joedayz/concentrador.

The intention is to show the great work of my colleague Jorge Pingo.

Jakarta EE and MicroProfile

In this article we will not use Spring Boot, we will use JakartaEE and Microprofile to be able to use the APIs that allow us to create Rest services with JAX-RS and persistence with JPA and CDI.

Apis from Jakarta EE:

Apis from Microprofile:


In this file, we configure the JDBC resource that we will have in Payara Server.

In Payara Server the JDBC Connection Pool will be defined:

And JDBC Resources:

Blaze Persistence

For the Backend, we are going to use this API that allows you to write JPA Criteria queries that use advanced SQL features. The source code for the project is on GitHub and there you can find various use cases.


Another project to use in this project is DeltaSpike which consists of a number of portable CDI extensions that provide useful features for Java application developers.
It requires a CDI implementation that is available in runtime.
These features are in addition to those provided by the CDI specification. In this link you can find the complete list:

In the file apache-deltaspike.properties we will configure:

globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy = org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy


By default the transaction type used by @Transactional is RESOURCE_LOCAL. If you set the type of transaction-type = "JTA" in the persistence.xml, you have to enable another TransactionStrategy in the beans.xml which is called org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy.

Context Root

The context root is defined in the glassfish-web.xml file like this:


In the model package, you will find the JPA entities and the entities related to views.


Thanks to DeltaSpike we can have a Repository that will implement for us the methods to persist our entity and we can also create our own Object Query.

This is very similar to Spring Data.


The business layer will be able to use the repository layer only using @Inject.

In this layer, we will find the ConsultaProductoServiceImpl.java class that the Criteria API will use to build the query according to the filters we have in the application. In addition to that, the implementation of paging.

To achieve this DeltaSpike is used:

import com.blazebit.persistence.deltaspike.data.Page;
import com.blazebit.persistence.deltaspike.data.PageRequest;
import com.blazebit.persistence.deltaspike.data.Pageable;
import com.blazebit.persistence.deltaspike.data.Sort;
import com.blazebit.persistence.deltaspike.data.Specification;


Finally, in this layer, we will have the REST endpoints. We start by configuring the class that inherits from the Application.

And then you can create your controller classes to handle the endpoints you need:

As you can see, you can define the scope, the main path and the exchange format (JSON) between server and clients:

public class EntidadFinancieraController 

Running the Backend

To test the application, first, make sure to start your payara server.

Then configure the payara server in your IDE to be able to deploy the application there:

When you run the application you will see the following result:

And you can try this endpoint (http://localhost:8080/api/v1/concentrador/opcion) to see the available options:

Configuring the Backend in the FrontEnd

In order to use the backend, we put the base endpoint in the environment.

BASE_ENDPOINT: 'http://localhost:8080/api/v1/concentrador'

When executing the application we will obtain the following result:

And as you can see, you can see the available options that the backend returns to us.

We hope you enjoy it.




Setting up JDBC Connection Pool and JDBC Resources in Payara for PostgreSQL


In Post # 1 of Comparabien.com.pe we saw how to install PostgreSQL and Payara. Now we will see how to configure a JDBC Connection Pool and JDBC Resource in Payara.

Starting the Domain

First of all, we make sure that the domain is started and the administrative site can be used on port 4848.

If I go to http://localhost:4848 / I will be able to access the Payara Server administrative console:

Creating a JDBC Connection Pool

First, we go to JDBC Connection Pool and click on the button New:

We enter the name of the connection pool, the resource type, the database driver vendor and click on the button Next:

The page shows us all the possible settings and suggested properties:

On this screen at the end you will see properties that I recommend you delete to start from scratch, just click on those two buttons and that's it:

The final result should be the following:

Then you must add your properties so that you can connect without problems. Be careful, your postgres user must have a password, blank passwords are not accepted. After adding the properties, don't forget to click on the button Finish:

Finally, we click on the ping button to see if we can connect without problems:

IMPORTANT NOTE: I have created a connection pool to the postgres database. If later you need to connect to another DB you must perform the same procedure.

Creating a JDBC Resources

First, we click on the New button:

We configure the JDBC Resource data:

The jdbc/macpostgres in my case I can already use in my java projects:

Alternative via commands

All of the above could be done via commands, I leave them as additional information.




Installing PostgreSQL and Payara Server

We are already July 11, 2021; and my plan is to show in the following posts a demo about the clone of https://comparabien.com.pe where the frontend has been built with Angular and the Backend has been built in two alternatives: Net Core and Jakarta EE + Microprofile running on Payara Server

Thanks to my colleague Jorge Pingo for being the author of the FrontEnd version in Angular and Backend in Java. The Net Core version is my own.

The demo can be built with the following requirements:

  1. Windows, Linux or Mac OSX. I'm going to use Mac Big Sur.
  2. You need to have Java 11 installed. You can use the Oracle JDK for free in development and testing, but if you need it for production it is better to use a free version like AdoptOpenJDK or similars.
  3. IDE for Java. I will use IntelliJ IDEA.  You can use Visual Studio Code as an alternative.
  4. IDE for Angular. I will use WebStorm. You can use Visual Studio Code as an alternative.
  5. IDE for NetCore. I will use Rider. You can use Visual Studio Code as an alternative or Visual Studio Community.
  6. To work with a database (DB) I suggest that you install the one that you will always use on your machine, but, if it is only for demo or temporary, a simple option is to install Docker for Desktop to install the DB you want only for a short time.
  7. To consult the different databases that we need, I use a single client: Jetbrains DataGrip

Installing PostgreSQL

I'm going to skip the installation requirements and download the installer and run it in my local pc for our demo.

You can download PostgreSQL from this link. There is a version for Windows, Linux and Mac OSX. The installer also gives you the option to install the PgAdmin which is a client for this database.

But, for Mac I recommend: https://postgresapp.com/ is super simple, you install it, create a server and your username is the same that exists in your machine, but without password (josediaz in my case).

It creates the databases: postgres, template1 and one with the name of your username.

Postgresapp permits you to indicate if you want that the database will be available when you do log in on your pc or open databases with iTerm. 

In the upper bar you can control the service according to your needs.

Connecting with DataGrip

DataGrip has support for different databases, and will allow us to connect to SQL Server and PostgreSQL.

I will connect to my PostgreSQL like this:

We do a connection test and we will be ready:

Installing Payara Server

I recommend using Payara Server for Jakarta EE and Microprofile projects, the community version is more than enough for our demo. But, if you need support, these guys have great plans for medium and large companies. In Peru, your friends from JoeDayz.pe can support you.

I have downloaded the full version:

I recommend a Tools folder for your tools. There I will download and use it in the following steps.

Now we are going to add it to the PATH. In Windows it is in system environment variables, in Linux in .bash_profile. In Mac Big Sur I will use my .zhrc file:

Next, we execute the following command to validate that everything works correctly:

asadmin start-domain

Add PostgreSQL Driver to Payara

First we need the driver, which you can easily get from https://mvnrepository.com/artifact/org.postgresql/postgresql/42.2.23 and download it to your machine.

Once installed, we can configure it with Payara when we want to create a pool of connections. We will do that in the next post and you can follow the demos without problems.