Posted the following question in jdeveloper forum today
I have who columns like created_by, creation_date, last_update_date, last_updated_by etc., in the table(and so the entity object). These need to get set based on the user logged in. Currently, I'm achieving the same by following logic:
1. Wrote my own TransactionImpl extending DBTransactionImpl2 and registeredthe transaction factory to the application module.
2. In my transactionImpl, there is a setter method: public void setUserId(int userId)
3. I've a filter to redirect the user to login page if not logged in. In the filter Istore the userid in the session, if user is authenticated.
4. Everytimein the DataAction PrepareModel phase, I invoke the methodsetUserId on the applicationModule passing the value from the session, whichsets the same in the TransactionImpl. Then in the EntityObject create method,I access this value to set the userId. I call the setter in all theaction class(so that if in the next request I get a different application moduleor a different transaction due to transaction/AM harvesting, the statevariable may be lost and hence in the preparemodel phase i explicity set them). Is this correct or any other way I can achieve the same
5. My next question is : how do I set these last_update_date and last_updated_by when the entity object is queried and changed. I can do thisin SetAttributeInternal Method(with a check that the index is not these twoattributes). However, this logic will then become tied to a particular entityobject. I want this logic to be written in my base class of EntityImpl so thatall EntityImpl extending my base EntityImpl will have this logic incorporatedautomatically.
Please let me know how can I acheive this.
Thanks,Krishna.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment