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
Showing posts with label transient attribute. Show all posts
Showing posts with label transient attribute. Show all posts
Sunday, April 24, 2011
Thursday, January 27, 2011
EOs with transient Attributes - will they be locked if no other change?
Found this post on an internal forum and thought of putting it down here :-
Problem :
We have some EOs with some attributes not mapped to any DB Table Column whereas some other attributes are mapped to DB Table columns. During runtime, sometimes we set only these "transient" attributes in the underlying EO and not the Column-mapped Attributes.
The question is, if we call am.commit(), will ADF Framework try to lock()/commit() these EOs with only changes in transient attributes?
Solution:
1.Modifying an attribute marks the entity as changed whether it's transient or not. To avoid this, you can use populateAttribute instead of setAttribute to set the transient attributes. If they are set from the UI, you can override setAttribute to call populateAttribute. The overview for EntityImpl javadoc here has a good explanation of set and populate methods. Same methods available in the view row.
2.Run time would mark the specific EO instance as dirty (STATUS_MODIFIED), and will take the EO through normal Txn cycle. However only those modified persistable attributes are posted back to DB
Problem :
We have some EOs with some attributes not mapped to any DB Table Column whereas some other attributes are mapped to DB Table columns. During runtime, sometimes we set only these "transient" attributes in the underlying EO and not the Column-mapped Attributes.
The question is, if we call am.commit(), will ADF Framework try to lock()/commit() these EOs with only changes in transient attributes?
Solution:
1.Modifying an attribute marks the entity as changed whether it's transient or not. To avoid this, you can use populateAttribute instead of setAttribute to set the transient attributes. If they are set from the UI, you can override setAttribute to call populateAttribute. The overview for EntityImpl javadoc here has a good explanation of set and populate methods. Same methods available in the view row.
2.Run time would mark the specific EO instance as dirty (STATUS_MODIFIED), and will take the EO through normal Txn cycle. However only those modified persistable attributes are posted back to DB
Subscribe to:
Posts (Atom)