• Tutorial
    • AWS
    • Oracle
    • WordPress
    • Azure DevOps
  • About me
Tutorial
    AWS
    Oracle
    Wordpress
    Azure DevOps
About me
cedricleruth - It's still magic even if you know how it's done
  • Tutorial
    • AWS
    • Oracle
    • WordPress
    • Azure DevOps
  • About me

How to fix Invalid column index SQLException in Oracle ADF?

The java.sql.SQLException: Invalid column index often occurs in ADF when your ADF View Object(VO) get desynchronized while adding a new column to an existing Entity object(EO). After adding the new Table column to your Entity Object and View Object the following error occur at runtime :

java.sql.SQLException: Invalid column index
     at oracle.jdbc.driver.OracleResultSetImpl.getBytes(OracleResultSetImpl.java:1464)
     at weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl.getBytes(Unknown Source)
     at oracle.jbo.domain.Number$1facClass.createDatum(Number.java:107)
     at oracle.jbo.server.OracleSQLBuilderImpl.doLoadFromResultSet(OracleSQLBuilderImpl.java:1322)
     at oracle.jbo.server.AttributeDefImpl.loadFromResultSet(AttributeDefImpl.java:2439)
     at oracle.jbo.server.ViewRowImpl.populate(ViewRowImpl.java:3842)
     at oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(ViewDefImpl.java:2378)
     at oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(ViewObjectImpl.java:6005)
     at oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(ViewObjectImpl.java:5834)
     at oracle.jbo.server.QueryCollection.populateRow(QueryCollection.java:3568)
     at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:3423)
     at oracle.jbo.server.QueryCollection.get(QueryCollection.java:2173)
     at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:5115)
     at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2935)

This error usually occurs when your View Object Query didn’t get updated while you added the new Entity Object Attribute. (Usually when you customized the View Object Query in Expert Mode)

To fix it you need to do the following steps :

  • In your Entity Object > Attributes, click on the green + Add Attribute from Table. Add your new Table Column
  • In your View Object > Attributes, click on the green + Add Attributes from Entity Object. Add you new Entity Attribute
  • In your View Object > Query, manually edit your Query to add the new Entity Attribute (YOUR_EO_NAME.YOUR_ATTRIBUTE_NAME)
  • Add your new attribute to your views

The error usually occur when you forget the 3rd step.

How to set JSF binding attribute programmatically in Oracle ADF?

One of the usual scenario in Oracle ADF is to need to set the value of a JSF View Object binding attribute programmatically in a Java Bean triggered by a user Action.

For example, I was once asked to set the value of a View Object attribute displayed as an outputText in JSF to a sentence when the user clicks a specific button.

There is multiple ways to implement this. From pure JSF Groovy to exposing the View Object class.

Here are two simple of them:

How to programmatically commit or rollback a transaction in Oracle ADF?

Running a commit or a rollback when a user trigger an Action Listener in your java Bean is the first thing you’ll need to know in Oracle ADF.

The easiest way to do so is to retreive the transaction used by your user in the Application Module and trigger a Commit or Rollback while catching any validation exception that could occur.

I also like to leverage the getViewObjectFromIterator from the JSFUtils class to simply commit the ViewObject the user modified.

Here is how i usually do it :

How to automatically select First value in ADF LOV inside a table?

Screenshots of and ADF View Object List of Value

When one of your attribute in your View Object is a List Of Values, ADF will add an unselected element that will be shown as the default value.
You will often be asked to have the first value being selected by default, to do that we need to add a function to the VO Implementation. (RowImplementation if the LOV is part of a table row)

Let’s see the following example of an ADF table with LOV on each line:

  • We have the VO that is used to display a table.
  • In this VO table, we have the NextStatus which is an LOV based on another VO (see http://www.awasthiashish.com/2015/02/adf-basics-set-multiple-lovs-on.html)
  • In the RowImpl.java we add the following function to return the first value if no value is already selected
  • In the Detail panel of the attribute add the following Default Value Expression: adf.object.defaultNextStatus()
  • In the Detail panel of the attribute set the refresh Expression Value to false to avoid picking the first value again in case of ppr/refresh

Screenshot of the Refresh Expression Value VO attribute option

Screenshot of the Refresh Expression Value VO attribute option

That’s it, the first value of the LOV will be automatically selected before display.

How to unapply a View Criteria programmatically from a View Object in ADF?

Screenshot of an ADF 11g View Object with View Criteria

Yesterday, I shared a quick tip on how to apply a ViewCriteria in your ADF Controller project. ( www.cedricleruth.com/how-to-apply-a-viewcriteria-programmatically-in-adf/ )

And if you’re using this snippet, you may also need to remove this ViewCriteria from the ViewObject programmatically.

A typical use case is a toggle button on top of an ADF table to only display specific data on demand.

Here is how to do so :

How to apply a viewCriteria programmatically in ADF?

Screenshot of an ADF 11g View Object with View Criteria

You often need to filter and modify the where clause of your view object programmatically in your controller bean depending on a user action. (for example, a click on a button will show a different set of data in the same table)

To do so you can either add the where clause programmatically in the controller or apply specified view criteria.
As a best practice and to allow a better maintainability I would always recommend applying a view criteria as any action on the data should be done in the model. (And it will be easier for you to update it if needed)

Want to be notified when there is more?

Get in touch:

Categories

  • AWS EC2
  • AWS Lambda
  • AWS S3
  • AWS Tutorials
  • Azure DevOps
  • Highlight
  • IT Architecture
  • Oracle ADF
  • Oracle Database
  • Oracle SOA Suite
  • Oracle Tutorials
  • Route53
  • Tutorials
  • Weblogic
  • Wordpress Tutorials

Read more about:

ADF Apache AWS Bean binding bpel Certificate cli cloud convert Database Deployment EC2 ERROR Exception file First Value GIT HTTPS Icons IllegalStateException iterator Java Jdevelopper lambda Oracle Oracle ADF Performance php programmatically RichTable route53 row S3 script sendRedirectforward soa sql SSL table View Criteria View Object VO weblogic WordPress