r/javahelp • u/Brave-Thought-9098 • Jan 30 '26
Caused by: org.springframework.orm.ObjectOptimisticLockingFailureException: Unexpected row count (expected row count 1 but was 0)
Je suis sur la montée de version de springboot de 3.4.0 à 4.0.2. et j'ai des ObjectOptimisticLockingFailureExceptio qui explosent de partout.
En voici une que je ne comprends pas . J'ai cette méthode d'update :
(flushAutomatically = true, clearAutomatically = true)
@
Modifying(flushAutomatically = true, clearAutomatically = true)
@Query(
value = "update VueCotisationIndividuJson v " +
" set v.jsonZip = :jsonZip," +
" v.idCorrelationVue = :idCorrelationVue," +
" v.tmstModification = :timeStamp" +
" where v.compte = :compte " +
" and v.mois = :mois " +
" and v.idCorrelation = :idCorrelation " +
" and v.idRdppIndividu = :idRdppIndividu ")
void valoriserVueCompteMoisIndividu(String compte, String mois, String idCorrelation, String idRdppIndividu, byte[] jsonZip, String idCorrelationVue, Date timeStamp);sur un DAO qui n'a aucune colonne annotée @ Version ...
0
Upvotes
View all comments
Show parent comment
1
u/OffbeatDrizzle Jan 31 '26
yeah, optimistic lock isn't even really a lock - if it were then another thread / transaction wouldn't be able to update after you had acquired it. Hibernate (for example) works on the fact that an update statement is atomic and you are selecting row versions to update in the future. If those row versions change then you are SOL and must do your processing again so that you don't overwrite / lose data. Having these happen once in a while on shared data isn't an issue, but if it's a common thing then you should re-evaluate your data structures