GORM refresh () method does not get the latest data from the database

After saving the changed username (using flush:true), the following expression evaluates to false:

User.get(u.getId()).name == u.refresh().name

The left side takes the changed username, and the right side returns the "old" value.

Ideas? Updating the operation of "u" in the following HTTP request will work.

+3
source share
1 answer

Is this done as part of a transaction? If your code is executed inside a transaction, then even with the help the flush: trueimmediate saving of changes to the database will not be saved. Changes to domain objects made in a transaction only turn red when the transaction ends.

+7

Source: https://habr.com/ru/post/1714723/


All Articles