Reputation: 504
I have an application with hibernate. There are two main threads, first one is collecting/modifying data and second one is saving data into database, in certain cases the program may try to modify and save the entity at same time.
Do i have to make all entities thread-safe (use only synchronized collections, atomic objects instead of primitives...) or hibernate takes care about it automatically?
Upvotes: 1
Views: 2002
Reputation: 23552
Hibernate instantiates objects per session, so classic synchronization is not needed (and would not be helpful).
The most common way to take care of concurrent data access and modifications is to use locks.
Upvotes: 1