Thursday, December 23, 2010

ADF Model: Creating Date Effective EO

Date-effectivity is an excellent feature available in Jdeveloper 11g. To learn the basics of date-effectivity in ADF, please go through my post Learning basic of Date Effectivity in ADF. With Jdev 11g, we can create date-effective objects and do date-effective operations using simple API calls. Before going into all those details, the first requirement would be creating Date-Effective EO.

The first requirement to create a DE-EO based on a table, the table should have two date columns to represent Effective Start Date(ESD) and Effecitve End Date(EED) of the record and these columns should be marked as primary keys along with id column. In other words, we need to define a composite key based on the id column and ESD and EED columns.

Creating Date Effective EO is same as creating normal EO. In addition, we need to do the following steps to make it date-effective.
1. Mark the EO as Date Effective by specifying the attribute Effective Date Type = 'EffectiveDated'. You can find this property in 'General' tab property inspector.

This will generate a new transient attributte called 'SysEffectiveDate' in the EO. Please find the screenshot below:

2. We need to specify which columns represent effective-date columns by checking the Check 'Effective Date' check box and selecting 'Start' and 'End' radio buttons for the effective-date columns which represent Effective Start Date and Effective End Date. Find the screen shots below:


3. Optional: Change the data type of SysEffectiveDate attribute to 'java.sql.Date' from 'oracle.jbo.domain.Number'. We'll often find it easier with native Java sql data types instead of using Oracle's jbo datatypes. It is recommended to use java native sql type(java.sql.Date) for all date type attributes in the EO.

That's it. Now, your EO is date-effective and supports date-effective operations on it's rows.

4 comments:

  1. Hi there, thanks for article. Could you provide any insight into why when I try this, the efffective date radio box (in the property inspector of the attribute) is greyed and not selectable?

    ReplyDelete
  2. Ok just worked out this is because I am doing it with a view object rather than an Entity Objects. This raises the next question (and it might sound very stupid) why do you need entity objects?

    ReplyDelete
  3. @Simon: Entity Objects represent to tables in database. And, the core of ADF is based on EOs and VOs. Whatever the operations(create, update, etc.,) you perform will finally commit to DB via entity objects. You can go through http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/bcentities.htm#sm0124 for more info in Entity Objects.

    ReplyDelete
  4. Hi Murali,

    I have a simple query.
    When a new row is created, I understand framework is creating new duplicate row with updated fields. My requirement is to create the new row with just updated attribute values & not every value from base row.
    Is there a way to customize this ?
    Please let me know.

    Thanks.

    ReplyDelete

Related Posts with Thumbnails