ObjectDB ObjectDB

Entity can be found by find() but not by query

#1

Hello,

we create an entity in transaction A, commit and close the transaction.

After that in transaction B we try to find the entity in the DB.

But we get always only a result with em.find(), with a query it is not always possible to get the entity, sometimes we get the entity and sometimes we don't get the entity by query.
Have you an idea what happens here?
 

edit
delete
#2

If transaction B started before transaction A committed, and it stored data using flush, then it may work until it commits on a separate snapshot of the database that includes its own updates but not updates of other transactions. Therefore, it is recommended to keep transactions short, and rely only on the state of the database when the transaction started.

ObjectDB Support
edit
delete
#3

The transactions don't run in parallel. The first transaction is closed before the second transaction will be opened.

Do you have another idea?

edit
delete
#4

In that case, maybe it is related to the query cache, although such an issue is not expected. You may try disabling the query cache to see if it helps. As always, if you can isolate the issue and present a test case that demonstrates it then this could be very helpful in understanding this situation.

ObjectDB Support
edit
delete
#5

It seems that the hint with the deactivated query cache works.

But the question is now why?

The DB Doctor does not show errors for the database file.

The error does not occur, if the database entity manager factory is closed and opened again, or we wait a certain time (maybe 10-20 seconds) after opening the database before we execute our use case.

Maybe there is a ObjectDB background process which needs to be finished before we execute the use case?

edit
delete
#6

The reason for this issue is unclear and it seems that a test case will be needed.

ObjectDB Support
edit
delete
#7

I created a smaller example. But this example runs without errors.

edit
delete
#8

In that case even a large example, i.e. based on your large parts of your application, which shows the issue consistently, might be fine. Even without your source code, as we will be looking on what happens in ObjectDB code in processing the specific query that misses the changes.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.