# Data integrity

**URL:** <https://community.ofelia.com/t/data-integrity/8483>\
**Category:** Q&A\
**Created:** [17 May 2017 08:27 UTC](https://community.ofelia.com/t/data-integrity/8483 "2017-05-17T08:27:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xat](https://avatars.discourse-cdn.com/v4/letter/x/f07891/32.png) [@xat](https://community.ofelia.com/u/xat)\
**Post date:** [17 May 2017 08:27 UTC](https://community.ofelia.com/t/data-integrity/8483/1 "2017-05-17T08:27:34Z")

</div>

Hi All,

I didn’t find explicit info in documentation so will ask here.

How does bonita handle “lost updates”? As far as I understood bonita uses hibernate which utilizes optimistic row locking through PERSISTENCEVERSION field in BDM. But it is not clear where transaction boundaries are.

I have a script in a operation in Service Step:

> import com.company.model.Specification  
> import com.company.model.DealTransaction
> 
> for(DealTransaction tr : dealTransactions){  
> //get Buyer and Seller Spec  
> Specification bs = tr.getBuyer()  
> Specification ss = tr.getSeller()
> 
> //Evaluate remains and lock specifications  
> if(bs.remains \>= tr.amount && ss.remains \>= tr.amount){  
> //Potential “update loss”
> 
> ```
> bs.setRemains(bs.remains - tr.amount)
> }
> 
> ```

What will happen if 2 processes try to execute this script simultaneously? May the **bs.remains** value be set to negative?

BR,  
Roman
