Collection shows different data between database and cache after two inserts [message #1835548] |
Sun, 06 December 2020 12:00  |
Eclipse User |
|
|
|
I am mapping the storage of an object "fleet" as follows:
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name="storage", joinColumns=@JoinColumn(name="fleet"))
@Column(name="units")
@MapKeyJoinColumn(name="object_type", referencedColumnName="id")
private Map<ObjectType,Long> storage = new TreeMap<>();
I open a new transaction that makes two changes in the storage:
1. inserts objects A, B, C, D, E
2. inserts A, B, F, G
Debugging the transaction I can see that the storage now has objects: A, B, C, D, E, F and G.
Databe also show objects A, B, C, D, E, F and G.
BUT... when I open the object fleet in other different transaction it shows the objects: C, D, E.
It is like somehow those objects that were in BOTH inserts were deleted from the persistance cache. They exist in the database, If I reboot the app the storage show the correct collection A, B, C, D, E, F and G.
Any idea why the persistance cache gets this corrupted data?
Thanks in advance
|
|
|
Re: Collection shows different data between database and cache after two inserts [message #1835596 is a reply to message #1835548] |
Mon, 07 December 2020 18:14  |
Eclipse User |
|
|
|
What are the exact operations you are putting on the Storage map? I don't see how two transactions can insert the same A and B pairs without getting an exception as it can only work once. I would assume one transaction clears the list/map and then inserts all it has, and it might be this initial clear operation (and how it is implemented on the container in the shared cache) that causes the issue.
|
|
|
Powered by
FUDForum. Page generated in 0.03680 seconds