JPA in JBStrap

The Java Persistence API (JPA) is a standard designed to store data in a relational database. Storing data requires a JPA implementation. There are different JPA implementations, with the most widely popular being Hibernate, Eclipselink and Toplink. JBStrap uses an Eclipselink implementation. Storing data using the JPA requires entities, also known as entity classes. Entity classes describe a database object, e.g. a view or a database table. An entity is a Java class in which the fields of a database object are represented as a Java variable. For entity classes, JPA annotations are used to indicate which field represents which piece of information, e.g. primary key, foreign key, the name of a database object, etc. Entities must be listed in a persistence.xml file where you can also specify metadata related to the database connection. The JBStrap framework currently uses the EclipseLink 2.6.2. JPA implementation. Please refer to the documentation to see how to create the entities you wish to work with.

JPA entity class

The entity class describes the physical data structure of the physical data source. The entity class is a POJO class and it needs to include every data column and key. It must contain the fields of the physical data structure and annotations for the data connection layer. These settings are required for the JPA to be able to perform queries.

Click here to read more about the JPA DAO solution in JBStrap.

The JBStrap framework uses EclipseLink 2.6.2 . For the JPA, you can include EclipseLink JPA layer annotations within an entity class :

Here's an example for a JPA entity (entity class):