Reputation: 59
I am facing a scenario where, I need to update the parameter and want to retrieve the modified value within same transaction
For example :
@Transactional(propagation = Propagation.REQUIRED)
public void modifiyParameter(Object object, BigInteger attribute_id) {
...
Attribute attrValue = object.getParameter(attribute_id);
attrValue.setValue("new_value");
object.setParameter(attr_id, attrValue);
...
object.getParameter(attribute_id); //getting old value instead of modified value
}
In the above case, It would return the old value itself, but I tried to wrap in separate transaction and I could able to retrieve the modified value.
My question is that, can't we retrieve the modified value from the bean itself within same transaction, instead of committing the inner transaction (i.e new transaction) and retrieving it from DB?
Upvotes: 0
Views: 58
Reputation: 377
If you have the value then why you want to fetch the value from DB, Use the same value. That is a good design from a performance and maintainability perspective.
Upvotes: 1