Sunday, September 18, 2011

Understanding Effective Dated Entities Behavior - Difference Between Dated and Effective Dated Entity Types

JDev Version: 11.1.2.

The Dev Guide says that:  "The primary difference between the effective dated entity type and the dated entity type is that the dated entity does not cause row splits during update and delete."

It says primary difference, but does not explain exactly what other differences are there.
Posted the question of forum post as well, but nothing is available:

https://forums.oracle.com/forums/message.jspa?messageID=9860255#9860255

I tried to compare the behavior of Dated Entities with Effective Dated Entities, and this is what I found out:
(For the setup, and project details, please refer to the earlier blog: 'Understanding Effective Dated Entities Behavior - Creation/Update/Delete').

For Create Operation

When I created a row for DatedVO (Dated Entity) with EffectiveDate as 2001-09-09, after commit, the following data was visible in the database:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First09-SEP-011Y

EndDate is not populated, but StartDate is populated with the Effective Date.
However, other attributes are populated like Sequence and Sequence Flag. Not sure why the behavior is like that.

When I created a row for MultiChangesSingleDayVO (Effective Dated Entity) with EffectiveDate as 2001-09-09, after commit, the following data was visible in the database:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First09-SEP-0131-DEC-121Y

All the Effected Dated attributes are populated.
So this is one difference.

For Update Operation

As discussed in the earlier blogs, there are multiple flags available in the oracle.jbo.Row interface for row update behavior. Let's compare the behavior of Dated Entity with Effective Dated entity for the following flag:

Row.EFFDT_UPDATE_MODE: When an effective dated row is updated in "update" mode, the modified row is end dated on the effective date and a new row is created with the changed values.

Used the following method to update the DatedVO row:

    public void updateDatedVODatedVORow( String text, Date startDate, Date effectiveDate, int mode){
       
        if (effectiveDate != null) {
            ApplicationModuleImpl rootAM = this.getRootApplicationModule();
            rootAM.setProperty(EFF_DT_PROPERTY_STR, effectiveDate);
        }
                ViewObjectImpl vo = this.getDatedVO1();
        Row row = null;
        row = (vo.findByKey(new Key(new Object[]{ 1, null , null, startDate}), 1))[0];
        if(mode==1)
                row.setEffectiveDateMode(Row.EFFDT_UPDATE_MODE     );
        else if(mode==2)
            row.setEffectiveDateMode(Row.EFFDT_UPDATE_CHANGE_INSERT_MODE       );
        else if(mode==3)
            row.setEffectiveDateMode(Row.EFFDT_UPDATE_CORRECTION        );
        else if(mode==4)
            row.setEffectiveDateMode(Row.EFFDT_UPDATE_NEW_EARLIEST_CHANGE_MODE        );       
        else if(mode==5){
            row.setEffectiveDateMode(Row.EFFDT_UPDATE_OVERRIDE_MODE         ); 
        }
        else if(mode==6)
            row.setEffectiveDateMode(Row.EFFDT_NONE_MODE         ); 
        
        row.setAttribute("Text", text);
    
        this.getDBTransaction().commit();
    }

For DatedVO, consider the following row in the table:
Before Method Call:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First01-JAN-111Y

Parameter Passed:

text = MODE_1
effectiveDate = 2012-01-01(YYYY-MM-DD)
mode = 1

After Update:


IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1MODE_101-JAN-111Y

As we can see, only text attribute is updated, everything else is unchanged.
So, seems like after row creation, framework logic does not update the effective dated attributes for Dated entities.
In the effective dated entities, this operation causes a new row to be inserted.

So, only this difference is documented in the Dev Guide, but other small differences are documented. Not sure why.

No comments:

Post a Comment