PROBLEM
When a domain object is added to a data access object, it implies that the application intends to persist objects for that domain object. The most basic persistence functions in Create, Read, Update and Write, and they are cummulatively referred to as CRUD operations
SOLUTION
For every domain object added to a Data Access Object, the developer can perform basic persistence functions using the Modify Data Access Object and Search Data Access Object steps. The Modify Data Access Object step is used for creating, update and deleting objects from a DAO, and the Search Data Access Object step is for reading object(s) from a DAO.
HOW IT WORKS
Operations - Create / Update / Delete
While the Modify Data Access Object step is very easy to configure, the object oriented concepts can be difficult to understand initially. While a relational database is ultimately going to be used to persist the data, an object oriented view of the data is different than a relational view of the data.
The Modify Data Access Object step supports two operations: Update and Remove. These operations are highly dependent on the primary key(s) defined for a persistable domain object. The key(s) must uniquely identify the object, and the ORM framework will use the keys to determine which objects should be removed, added or updated. For the update operations the ORM framework will determine whether to do an update and an insert based on the keys. If an object with the same keys already exist, then the ORM framework will use an update SQL statement. If an object with the same keys doesn't exist, then the ORM framework will do an insert SQL statement.
The following examples will demonstrate how the Modify Data Access Object works.
(A) - The data access object being edited has 3 objects (A, B, C). The Modify Data Access Object operation being performed is an “Update” operation, and the operation input is a single object (D). The effect of this operation is that the data access object will have four objects in it, the original three plus the “D” object.
(B) - The data access object being edited has 3 objects (A, B, C). The Modify Data Access Object operation being performed is an “Update” operation, and the operation input is a single object (A), which has been modified in the application. The effect of this operation is that the data access object will have three objects.
(C) - The data access object being edited has 3 objects (A, B, C). The Modify Data Access Object operation being performed is an “Update” operation, and the operation input is a collection with two objects, an updated "A" object and new "E" object. The effect of this operation is that the data access object will have four objects, the original two unaltered objects (B, C), the updated "A" object, and the new "E" object.
(D) - The data access object being edited has 3 objects (A, B, C). The Modify Data Access Object operation being performed is a “Remove” operation, and the operation input is a single object (A). The effect of this operation is that the data access object will have two objects in it.
(E) - The data access object being edited has 3 objects (A, B, C). The Modify Data Access Object operation being performed is a “Remove” operation, and the operation input is a single object (E). Since the data access object didn't have an "E" object to begin with, the effect of this operation is that the data access object is unaltered.
(F) - The data access object being edited has 3 objects (A, B, C). The Modify Data Access Object operation being performed is a “Remove” operation, and the operation input is a collection with two objects (A, B). The effect of this operation is that the data access object will have one object (C).