OHDSI / WebAPI

OHDSI WebAPI contains all OHDSI services that can be called from OHDSI applications
Apache License 2.0
128 stars 166 forks source link

Hypersistence Optimizer Issues: Critical: BidirectionalSynchronizationEvent #2263

Open ecruz165 opened 1 year ago

ecruz165 commented 1 year ago

https://vladmihalcea.com/hypersistence-optimizer/docs/user-guide/#BidirectionalSynchronizationEvent

The Hypersistence Optimizer report suggests adding synchronization methods.

When mapping a bidirectional one-to-many or many-to-many association, you need to synchronize both sides of the association. Without synchronizing both sides, Hibernate cannot guarantee that the association state changes propagate to the database.

More, unsynchronized bidirectional associations can also lead to very subtle bugs that are hard to reproduce. For this reason, it’s best to have two utility methods (e.g., addEntity and removeEntity) on the mappedBy side of the one-to-many or many-to-many associations.

chrisknoll commented 1 year ago

My understanding is that Spring JPA will wrap Entity Bean manipulation into a 'session transaction' such that it will ensure these updates are ACID. Are you worried about different users manipulating the same entity at the same time? If so, I wouldn't put this at a high priority because Atlas is not a high-transaction system, you have a group of users working on their own assets where it's very rare that there would be any cross-talk between updates.

If you're talking about another context, could you elaborate on the specific use case in question?

ecruz165 commented 1 year ago

This recommendation is marked as critical. It's nice to have and removes critical warnings from the Hypersistent analyzer reults. I made the change already. Pull it in if you see the value.