Jpa Datadescriptor

JPA DataDescriptors are used to describe the data structure in an SQL database. A JPA DataDescriptor has access to the data through the JPA layer, so a DataDescriptor must use entity classes. JPA DataDescriptors enable you to read and write data in an SQL database.

The JPA DataDescriptor is the default data descriptor type in the JBStrap framework. If you don't specify the connectorType attribute in the data descriptor, the framework creates a JPA DataDescriptor from an XML descriptor.

Creating a JPA DataDescriptor in an XML structure:

Programmatically creating a JPA DataDescriptor that corresponds to the above XML:

The JPA DataDescriptor enables you to perform any data handling operation: reading data from the database, updating and deleting data.

Fetches all records from the database by using the data descriptor:

Fetches all records satisfying the specified criteria using the data descriptor:

Fetching a record using its primary key:

Saving a record to the database using the data descriptor:

Removing a record using the data descriptor:

DataDescriptors also support transaction handling. To handle transactions, you must specify an SQLTransaction for the DataDescriptor.

Fetching a record, then modifying and saving it within a single transaction: