Header Ads

Synchronizing Entity Objects with Database Changes

ADF
In my previous posts
I have described how to create Entity Objects in ADF using JDeveloper. In this post I would like to venture how to synchronize the Entity Object with Database. 
As we know EO creation is an wizard based technique which is provided by JDeveloper. http://www.askqtp.com/2012/04/how-to-create-entity-object-in.html link talks about the EO creation from database.
What is EO?-An entity object is a cache for holding records from an underlying database table.
An EO is having six parameters

General
Attribute
Business Rules
Java
Business Events
View Assessors

The rule of thumb is what ever there in the database table can be captured by JDeveloper while dragging as a component.
So after successful creation of EO all these six parameters are set and corresponding backend use case and code is generated.
Now say due to some reason your database got changed. The table it was connected was changed . The EO becomes invalid or out of Sync with data table.
Below are the two ways how to make it sync with data table again.
Process 1: Delete the EO and create one new…this is applicable if the project is new or in an early stage of the development.

Step-1. Right click on the effected EO and click on Delete. It will check the usage and will delete the same
.image
Step-2   Follow http://www.askqtp.com/2012/04/how-to-create-entity-object-in.html this and create a new EO .
Process-2: Say the project is bit older and the EO is having lot more usage in different areas. Now deleting the same will create a lot of problems.Now we need a shortcut way to rectify the same.
Step-1. Right click on the effected EO and click on synchronize with database.
image
Step-2: This will open up a pop up. Now to synchronize all click on the corresponding button. The focus has to be in root level.
image
If you want to synchronize in child level …select the child level node. The corresponding Synchronize button will be enabled and click on that.
image
Step-3: Write this change log to a file(.txt). Click on Write to file button
image
Step-4: On click Save the change log is created
image
Step-5: Open the txt file this will give you the structure of change.

Entity :EmployeeEO
|__Attribute :DepartmentId
|____Change Mandatory to:false
|__Remove Key Constraint: EmployeesDepartmentIdCheck
This is the way how you can synchronize the EO with the data table. 
There are cases when this method will not work properly...Please go through http://www.askqtp.com/2012/04/how-to-work-with-entity-object.html 
for advanced customization.



 
Powered by Blogger.