I am of the current understanding as I learn about EJB's in school:
In CMP (Container-managed persistence), the container will tell the database synchronize row in database when different entity beans try too access the same row at the same time.
As far as I know though, every database has a background mechanism that auto synchronizes every row when there are multi accesses to it. So, when developers program against a database, they don't care about underlying synchronous access to rows.
So, my question is - if statement 2 is true, why does an EJB container need to synchronize entity bean access to database rows? If my thinking is wrong, please correct me.
If I understood your question correctly, you're asking about locking.
By default JPA provides optimistic locking controlled with the @Version annotation.
You should check for OptimisticLockException
s.
Other locking modes are possible:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.