Tuesday 10 December 2019

What is partial commit in adf? getDbTransaction().postChanges()

postChanges() is a method of DbTransaction that is used to sync the cache layer and database. It basically means when you call postChanges() method is will send all the data that is in the cache to the database and synchronizes both layers.

Example 

Let's take an example of EmployeeVO which is based on an Entity Object.
We will create a row by calling createInsert() method of view object and fill the values. The row will be available in the cache memory. 

Suppose there is a database function that needs the data currently created for performing some operation based on the row which is created.
If you call the database function, the function will not get the data as the row is not available in the database.

The row with the value is currently is in the Model cache, if you want to send that data to the database then you will call the method postChanges(). The method pushes the data into the database with an insert statement in this case.
If a value of a row is updated, then an update statement will be fired when postChanges() is called.

Now the row is posted in the database in the current session. As the row is in the database it will be available for any database function or procedure to perform any operation.

Let's take a use case.

1. The user will create a row of Employee.
2. Entry employee details and then click a button "Update Commission Details".
3. On click of "Update Commission Details" a database function will be called and will do some calculation based on data entered by the user. Then update the Commission of the employee which was created by the user.
4. After that the user will see the commission on the screen.
5. Save the record.

postchanges-in-applicationmodule

No comments:

Post a Comment