Quick Version
Basically, I\'m updating a Hibernate Table and subsequent queries are loading a stale value.
Detailed Version
I discovered the problem, but it introduces something else.
Basically, when modifying a Book
object's List
field, Hibernate does three things:
Book
and PageContent
pageNum
field on each PageContent
objectBook
object from the Second Level Cache.This ensures that subsequent queries will search for new objects, etc. However:
PageContent
object from the Second Level CacheAs a result, any query for the list of pages will run properly, but then will fall back on stale Second Level Cache values for the actual data.
I presume this is because Hibernate feels a pageNum
change is not a change in data but a change in behind-the-scenes management. However, that is the data that I would like to read and display.
The solution is to manually refresh every page after the insertion/deletion has occurred.