Sunday, April 24, 2011

Removing hard coded set-attribute in EOImpl

I was faced with the below issue and posted it on several forums :-

Some EO's in my application have hard-coded setAttribute in order to get around an ADF issue where we have these transient attributes for EO assocations, but they don't show up on newly created rows.


For example:

protected void create(AttributeList attributeList) {
super.create(attributeList);
this.setAttribute("TransientAttribute1","SOME_LITERAL_VALUE1");
this.setAttribute("TransientAttribute2","SOME_LITERAL_VALUE2");
this.setAttribute("TransientAttribute3","SOME_LITERAL_VALUE3");
}

Our requirement is to get away with this method and instead achieve the above using either groovy expression or derived from sql expression. Using this, the values of the Transient attributes show up as null currently. We need to have the literal values show up on creating a new row.

Finally, what worked for me was :-

I had the setAttribute in the EOImpl file removed.
Instead I had the literal values set in the 'Literal' window and the 'Derived from SQL expression' window.
The test cases for most entities passed fine.
I added tests in entity unit tests to test the default values for common association attributes in case of new row creation as well as fetch row from DB. They worked perfectly fine in both cases

2 comments:

Unknown said...

nice blog. more useful for me.
i agree point as you said.

but my usecase is here.
experts,
i had problem with this.
https://forums.oracle.com/forums/thread.jspa?threadID=2295513&tstart=0.

Unknown said...

https://forums.oracle.com/forums/thread.jspa?threadID=2295513&tstart=0