Saturday, July 7, 2012

ADF 11g "Cannot convert -2 of type class java.lang.String to class oracle.jbo.domain.DBSequence"

Have you ever encountered the above error? The reason for this could be manifold. Go through the following list and hopefully should resolve it if everything is 'as expected'.

1. Check whether you have any validators on the ADF component

2. Check for any 'Converters' that might run

3. Remove the mandatory, maximumLenght properties of the ADF component and check if this resolves the issue

4. Finally, go to the source view of the Entity Object attribute which is modified to DBSequence and check if the columnType, Type, SQLType properties are fine which could cause the casting error. A valid attribute can be as shown below;

<Attribute
    Name="RequestId"
    ColumnName="EQUEST_ID"
    SQLType="NUMERIC"
    Type="oracle.jbo.domain.DBSequence"
    ColumnType="NUMBER"
    TableName="REQUESTS"
    PrimaryKey="true"
    IsUpdateable="false"
    Domain="oracle.jbo.domain.DBSequence"
    RetrievedOnInsert="true">
    <DesignTime>
        <Attr Name="_DisplaySize" Value="39"/>
    </DesignTime>
</Attribute>
 
On a side note, more often than not, if the primary key is generated by a DBSequence using the trigger approach, it often shows a negative integer value in the element on the UI. Oncommit, the value gets replaced with the DB sequence. In many cases this might look ugly to show a negative number to the user. To overcome this, check for the "Default Value" property for the attribute in the entity object and remove it.
 
Usually, the DefaultValue property will have a value as "@0" which causes the VO to render a temporary negative integer value on the UI.

No comments:

Post a Comment