以下はテーブル構造です

方式
残高 = 元の金額 + 残高(以前)
50=50+0 ID(1)
200=150+50 ID(2)
2 行目に関しては、hibernate session.save();を使用してバランスを更新する方法です。挿入クエリを書き出そうとしましたが、HQL は値による挿入をサポートしていませんが、他のテーブルからの選択をサポートしていることを知りました。
In HQL, only the INSERT INTO … SELECT … is supported; there is no INSERT INTO … VALUES. HQL only support insert from another table. [ソース]
休止状態を使用している場合は、問題I first get the balance of max id of customer 1ありthen pass the balance to the new objectません。
ただし、マルチユーザー環境ではone user get the balance of max id of customer 1、その間other user insert the new row and update the balance. 残高を取得する最初のユーザーは古いbecause when first user transaction geting the balance other user insert new row and update balanceです。この場合、最初のユーザー トランザクションは、2 番目のユーザー トランザクションを更新する前に取得した以前の残高に対して間違った残高を挿入します。
休止状態には、この種の状況を制御する速報機能がありますか?
最新の残高で hibernate session.save() を使用してトランザクションを保存する方法。?
私を更新してください!