Showing posts with label Business Components. Show all posts
Showing posts with label Business Components. Show all posts

Monday, March 10, 2014

ADF: DBSequence attribute got an empty value for a new row

From the section "4.10.10 How to Get Trigger-Assigned Primary Key Values from a Database Sequence" in the documentation "Developing Fusion Web Applications with Oracle Application Development Framework" at:

http://docs.oracle.com/middleware/1212/adf/ADFFD/bcentities.htm#ADFFD19777

We have the following description:
"When you create a new entity row whose primary key is a DBSequence, a unique negative number is assigned as its temporary value. This value acts as the primary key for the duration of the transaction in which it is created. "
But sometimes, for some reason, you could come across the problem that a DBSequence attribute remains empty for a new row. In my case, it happened to an entity newly created after I manually switched Data Type Map of the model project from Java Extended for Oracle to Java.

To fix this problem, you need make sure DefaultValue and Domain properties of the attribute are there as the following highlighted lines:

<Attribute
    Name="ContentItemId"
    Precision="19"
    ColumnName="CNT_ITEM_ID"
    SQLType="NUMERIC"
    Type="oracle.jbo.domain.DBSequence"
    ColumnType="NUMBER"
    TableName="FMM_CNT_ITEM"
    PrimaryKey="true"
    IsUpdateable="while_insert"
    DefaultValue="@0"
    Domain="oracle.jbo.domain.DBSequence"
    RetrievedOnInsert="true">

The domain object and the magic default value "@0" cause the view object to generate a negative number as the temporary key.

You can also find a discussion on this issue at:

https://java.net/projects/adfemg/lists/issues/archive/2013-05/message/64

Friday, March 7, 2014

ADF: Manually change Data Type Map for a BC project

After I worked on a new ADF project for a while, I decided to change the Data Type Map of my data model project from the default Java Extended for Oracle to Java.

As described in the section "How to Initialize the Data Model Project With a Database Connection" of the documentation "Developing Fusion Web Applications with Oracle Application Development Framework" at:

http://docs.oracle.com/middleware/1212/adf/ADFFD/bcintro.htm#ADFFD133

Once you save project selections in the Initialize Business Components Project dialog, the project is considered initialized. You will not be able to change the data type map of the initialized project and it is not recommended to change the SQL platform after you have created business components.

So, I looked for the configuration entries for the data type map across the project, and ended up with two files, "bc4j.xcfg" and ".jpx" file of the model project.

I made a change as follow, in the ".jpx" file:

-  <Attr Name="_jbo.TypeMapEntries" Value="OracleApps"/>
+  <Attr Name="_jbo.TypeMapEntries" Value="Java"/>

and changes in "bc4j.xcfg", for all application module configurations:

-  <Database jbo.locking.mode="optimistic" jbo.TypeMapEntries="OracleApps"/>
+  <Database jbo.locking.mode="optimistic" jbo.TypeMapEntries="Java"/>

This seems to work fine in my case. It's a small and simple model project anyway.