Using JPA in an application

So far, we have looked at how to create EJBs and CDI-managed beans and how to inject the beans in classes. We then looked at defining entities, defining relations between entities, and mapping entities to the database tables. Let's now combine all of this information to create a simple application where we will create an identity such as a person object and persist it into the database. Later, we will enhance this module so that it can carry out read, update, and delete operations.

Let's create a simple JPA project using Maven with the following dependencies:

  <dependencies>        <dependency>            <groupId>org.jetbrains.kotlin</groupId>            <artifactId>kotlin-stdlib</artifactId>            <version>${kotlin.version}</version> </dependency> ...

Get Kotlin for Enterprise Applications using Java EE now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.