Configuring Jakarta Persistence
Jakarta Persistence requires a bit of configuration before our code can work properly. A data source needs to be defined. The data source specifies information on how to reach the Relational Database Management System (RDBMS) system we are connecting to (server, port, database user credentials, etc.). There are two ways it can be set up. It can be done via the Jakarta EE implementation configuration, but how to do this is dependent on the specific implementation.
It can also be done by annotating an application-scoped CDI bean via the @DataSourceDefinition annotation.
There are advantages and disadvantages to each approach. Defining the data source as part of the Jakarta EE runtime configuration allows us to deploy our code to different environments (development, test, production) without having to make any modifications to our code. It also prevents adding any user credentials to our source. Using @DataSourceDefinition
works across Jakarta EE...