Writing data to the physical data source
To save a record to the physical data source, you simply need to call the DAOAPI.save() method. Data records are a generic data structure in JBStrap, so you need to specify the entity class (data class). Entity classes are associated with physical data structures in your physical data source. This is how the DAO "knows" where exactly to save a data record. Once the data record is saved to the physical data source, the DAO API returns the saved data record to the program logic. If there are trigger-calculated fields, then the resulting new values are returned to the program logic when saving the data record.
To save a data record to the physical data source using JPA DAO, use the following code:
The below sample code shows how to implement a proper save method call in the ElasticSearch API:
Reading data from the physical data source
To read data from the physical data source, we can specify a entity class name and optionally also a DataRecord and Criteria. These three parameters are passed to the DAOAPI.fetch() method. This method of the DAO API forwards the fetch request to the physical data source. The DAO API returns a list of records corresponding to the specified criteria.
To find a list of records using JPA DAO, use the following code:
Let's see how to properly implement a find method call in the ElasticSearch API: