The first step in creating RDBMS backed form data model is to configure Apache Sling Connection Pooled DataSource. To configure the data source, please follow the steps listed below:
The JDBC Connection URI, Username and Password will change depending on your MySQL database configuration.
The get service expects a value mapped to the empID column of newhire entity.There are multiple ways to pass this value and in this tutorial the empID is passed through request parameter called empID.
The associations defined between database entities are not created automatically in the form data model. The associations between entities need to be defined using the form data model editor. Every newhire entity can have one or more beneficiaries, we need to define one-to-many association between the newhire and beneficiaries entities.
The following steps will walk you through the process of creating the one-to-many association
Select newhire entity and click on Add Association
Provide a meaningful Title and identifier to the association and other properties as shown in the screenshot below
Click on the edit icon under the Arguments section
Specify values as shown in this screen shot
We are linking the two entities using the empID column of beneficiaries and newhire entities.
Click on Done to save your changes
Our form data model now has get service which accepts empID and returns the details of the newhire and its beneficiaries. To test the get service, please follow the steps listed below.