Skip to main content

Marking an Entity Object as modified

There are use cases where developers may need to explicitly set the Entity Object state as modified so that it becomes 'dirty' and participate in the 'transaction commit' cycle. This scenario usually arise where you may have Entity Objects(not exposed through UI) whose attributes needs to be populated by the system as 'history columns' or through database trigger, when a transaction gets committed. Please note that only dirty entity instances participate in transaction post cycle. How to mark an entity instance as modified? Unfortunately, there is no public API available at EntityImpllevel to mark the instance as as modified (EntityImpl::setState() is a private method). A work around solution for this specific scenario is to brutally set one attribute of the EntityImpl instance with its current/original value.

//purely a work around,
//currentValue is same as someEntityImpl.getSomeAttribute()
someEntityImpl.setSomeAttribute(currentValue);

This action would mark the instance as dirty('STATUS_MODIFIED'), and it becomes a candidate for transaction post cycle.

Comments

Josh said…
Where to set this in the EOImpl?
Should it be placed inside the EO create method?
Josh said…
Where to set this in the EOImpl?
Should it be placed inside the EO create method?

Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…