• pega4engineers

EXTERNAL DATABASE TABLE CLASS MAPPING

Let's see how to use Database Class Mapping Wizard here.

We already know that there is two separate database schema for Rule and Data introduced by Pega 7.

1. PegaRules - Contains Rule Tables

2. PegaData - Contains all the Work and Data tables


Why do we need to map the class to a data table?

Pega always stores the user session data in memory using clipboard pages. But we may need to store this data for a long time for future references. Pega supports the mapping of this data to a table in an external database. However, only concrete classes can be mapped to any external database.


What are Abstract and Concrete classes?

An abstract class is a rule (an instance of the Rule-Obj-Class class) created to support the definition of rules, including other classes. Such rules can be inherited by subclasses of the abstract class. Rules with a class as a key part (such as properties, activities, flows, data transforms, and so on) can apply to an abstract class.


A class that is not abstract is concrete. Unlike abstract classes, concrete classes can have instances stored in the database. A selection on the Class rule form determines whether a new class is abstract or concrete.


How to connect a table from the database to Pega?

1. Install any P{ostgres Database GUI in your system in case you don’t already have one. There are many GUIs available on the internet like pgAdmin4, DBeaver, Navicat, DataGrip, OmniDB, etc. We have Used pgAdmin4 here.

2. Let's see how to access the Postgres Database through pgAdmin4.

a. Launch pgAdmin4 and create the server.

b. Configure the server with Name and Server group, and establish the connection settings.
















c. Set the Hostname/address, Port - as described or added while installing the GUI, Maintenance database name, Username and password (if required) and Role (if required).
















d. If the connection is established successfully, you can access all the Pega related tables here. Expand the Postgres >> schemas >> data/rules for the Pega related tables.

e. We shall now create a table here and call it "studentinfo" and map it to the Pega using Database Class Mapping Tool.

f. You can either create a DB table using a query or by using GUI. Here we have used GUI.

g. Right-click on Tables under data and click create.

h. Enter the Name, Owner and Schema of the table in the General tab.














i. Create all the required columns in the Columns tab and click Save.














j. Enter the select*from query to view the table.

k. Include all the values or records that are to be present inside the table using a query.

We have finally created the table manually in the database. Let's now map this table with Pega using Database Class Mapping Tool.

3. Move to Designer studio >> Data Model >> Classes & Properties >> database class mappings.

4. Click on the ‘New External Database class mapping’.

5. In the modal dialog box that appears, fill in Database table details and Ruleset class details.

  • Step 1: Specify database table – Provide the DB name, schema, DB table name.

  • Step 2: Specify ruleset class – Specify the ruleset details and a new Class name.

















  • Step 3: Map database table columns to properties in the ruleset class

Key – You can check the column to make it as key to the table

Property Name – You can select the properties in Key column and provide a Property Name in property column.

Map All/None – Creates new properties, if checked. Pega creates new properties in the specified class.

6. Click Submit. Since we have mapped the table to the data class, we can access the data table in Pega.

7. To view the table in the Data Explorer, select Add data type and Choose the proper table.












8. We have configured source to check if the properties are properly created and mapped in Pega.

9. You can finally see the table along with all the records which you added in the database.

What are the rules that get created by the wizard?

1. A new concrete class – Wizard creates a new concrete class that we provide.

2. New properties – You can check the external mappings tab.

3. A Database table instance.



Happy Learning !!


1,000 views