Common Methods in EOVO Impl

Embed Size (px)

DESCRIPTION

merhods

Citation preview

Common method in Entity/ViewObject Implementation classes:Its always recommended to call super. to let ADF do its job,before custom code gets executed.Unless one handles logic completely on one's own.EntityImplprotected void prepareForDML(int i, TransactionEvent transactionEvent) {Method calls doDML at the end.protected void doDML(int i, TransactionEvent transactionEvent) {}Does the DML operation. This is where everything gets into the DB.All the INSERT, UPDATE, and DELETE statements run here!public void beforeCommit(TransactionEvent transactionEvent) {}Invoked before commit is called. By this time the changes are already present in the DB.So any logic that needs updated data in the DB can be writtern here.public void afterCommit(TransactionEvent transactionEvent) {}Similar to above method.protected void validateEntity() {}Call executes the entity level validations defined on the EO.Gets invoked when use moves from one row to another.public void lock() {}Executes a SELECT FOR UPDATE based on the DML operations, for eg like UPDATE or DELETEprotected void create(AttributeList attributeList) {}Apart from declarative defaulting override the method to have custom creation and defaulting logic for attributes.public void remove() {}Self explanatorypublic void postChanges(TransactionEvent transactionEvent) {}Calls prepareForDML and later doDML to post the changes to DB.Its only after the method's execution data changes are available in the DB before being committed. If apps need some PL/SQL or any procedure to be invoked with updated data they can do it here after super or in doDML as needed.public boolean isAttributeUpdateable(int i) {}Returns true if the attribute is updateable. Override the method to define own logic, to whether an attribute is updateable or not apart from default WHILE_NEW, NEVER or ALWAYS.The super.isAttributeUpdateable returns the declarative setting.Eg: Lets say Commision is updateable only when Salary is greater than 5000.This cannot be declaratively achieved. One can write that logic here.if(index==COMM)return this.getSal()!=null && this.getSal().doubleValue()>5000elsereturn super.isAttributeUpdateable(index) //Default setting for the restprotected void setAttributeInternal(int p1, java.lang.Object p2) { }Triggers attribute level validations. One can see that every attribute setter has setAttributeInternal; It's because of this call the attribute level validations get fired.protected void populateAttribute(int i, Object object) {}Use it to set attribute value by skipping any attribute level validations. The default setAttribute fires validation after value is set and does not update the target value if any validation fails.protected void populateAttributeAsChanged(int i, Object object) {}Same as above but instructs ADF that the attributes value has changed.ViewObjectImplprotected ViewRowImpl createRowFromResultSet(Object object,ResultSet resultSet) {}Executed after the VO SQL query runs.Its here the query result set is iterated and each result is split and pushed to respective entity cache.Override to run any logic to default attribute values based on PL/SQL functions or any other logic after query is executed.One can also create SQL derived attributes for simple SQL procedure or function invocation for an attribute.public void beforeCommit(TransactionEvent transactionEvent) {}Invoked before commit is called. By this time the changes are already present in the DB.So any logic that needs updated data in the DB can be writtern here.public void afterCommit(TransactionEvent transactionEvent) {}Similar to above method.public void postChanges(TransactionEvent transactionEvent) {}Calls prepareForDML and later doDML to post the changes to DB.Its only after the method's execution data changes are available in the DB before being committed. If apps need some PL/SQL or any procedure to be invoked with updated data they can do it here after super or in doDML as needed.public boolean isAttributeUpdateable(int i) {}Same as EOpublic RowSet createRowSet(String string) {}A rowset is a memory representation for the VO rows. One can create a row set to iterate over rows and access row attributes. ADF has a default rowset and a default rowset iterator. It's always recommended to create one's own rowset and rowset iterator to process rows than manipulating the default rowset. To avoid memory leaks always close rowset and its iterator after processing.public RowSetIterator createRowSetIterator(String string) {}Creates a row set iterator. This iterator is created on the default row set. Always create a custom rowset and create iterator with the custom rowset. To avoid memory leaks always close rowset and its iterator after processing.public Row getCurrentRow() {}The call is primarily routed to default rowset and returns the current selected row. The default rowset is used for UI row currency (meaning current selected row).protected void create() {}Call to create a new row.public Row createRow() {}Call to create a new row in the vo.ViewRowImplpublic void validate() {}Internally invokes validate for corresponding entities.protected void setAttributeInternal(int p1, java.lang.Object p2) { }Same behavior as EOpublic boolean isAttributeUpdateable(int i) {}Same behavior as EO