Wednesday, November 17, 2010

Entity Inheritance And Passivation-Activation Possible Problem in ADF 11g


It seems to be a very strange behavior when it comes to Entity Inheritance and Passivation-Activation.

Download the Sample Application

Lets Say that we want to create an application that wants to do the following:

1) Use Entity Inheritance

2) Have one View Object and interact with it, leaving the inheritance do the magic

3) Create an insert Operation to the subtype. The method will reside in the AM and exposed to the client interface.

4) Create a sample jspx and drop a Form of the View Object.

5) Drop the insert operation onto the jspx  sample page.

6) Have our application tested with and without the AM pooling.


Lets take those steps one by one:

As Far as the Entity Inheritance, we will follow the ADF documentation that describes us how to do it:

First we create the Employees entity.
In the Employees Entity, we set the attribute JobId as the discriminator Attribute. We do not set any Default Value in this attribute since we want to handle all case that are not included in the subtype.

Next, we create another Entity that extends the Employees entity. The name is EmployeesAC_ACCOUNT

In the EmployeesAC_ACCOUNT we have set a Default Value in the Discriminator Attribute: "AC_ACCOUNT"

To create a View Object with prolymorphic entities, we follow the ADF documentation that describes how to do it:

This means that we create a viewObject based on the entity, and then add the subtypes

3) In Order to create a row in the subtype, we follow the documentation of the step 2) and specifically the chapter: Creating New Rows With the Desired Entity Subtype

So we created a method in the Application Module that does the following:

4) Next, we create a simple page with a Form of the Employees View Object.
A Drag n Drop in the ADF world..

5) We expose the AM method in the client interface and we drop it as button in the Form

In Result we have the following layout:

If we run the application and press the create button we will see the following:

As you can see, the discriminator value has the value passed from the create method.

If we set values to all fields and then press submit, the form is submited correctly.

This functionality works very well.

5) But according to decoumentation:

We have to test our application with the Inheritance we did, without the Application Module pooling.
Note: for a detailed explaination of how to remove it you can check a blog post:

After we uncheck the pooling in the Application Module. we run the page again.

We press the create button and we insert data. But when we press submit, where the passivation and the activation takes place we have error messages on the page that the required attributes have no values!!

so, from this state:

we press submit we end up to this state:

Am I missing something here?

Download the Sample Application



Related Posts Plugin for WordPress, Blogger...