I've been going thru the docs and I can't seem to find an answer to this, supose you have a book entity and it can hold a maximum of 3 chapter entities, How would you prevent that race conditions happen where more than 3 are added in concurrent sessions?
eg:
Say you'd load the parent book enity in both sessions, they would get added to the first level (transaction scope) cache, now both sessions have a seperate refference to the parent. say the book had allready 2 chapters attached a bussinesslogic check for book.chapters.size() > 3 would both return true but when you add an entity to both objects you'd end up with 4! violating my constraint
|