Page 1 of 1

About Question enthuware.oce-jpad.v6.2.462 :

Posted: Sat Dec 24, 2016 2:39 pm
by johnlong
Option "Retrieve the entity again using a query" is marked as wrong and explanation says : "JPA specification does not specify what happens to a managed entity if it is included in a result of a query. In many cases, the entity manager does not refresh the existing entity in the persistence context."
But on other hand JPA specification says that result of the query (in case of FlushModeType.AUTO) shall reflect current state, and should not return stale data.

Re: About Question enthuware.oce-jpad.v6.2.462 :

Posted: Sun Dec 25, 2016 12:52 pm
by admin
Right, but that is only in the case of in case of FlushModeType.AUTO.

Re: About Question enthuware.oce-jpad.v6.2.462 :

Posted: Sun Dec 25, 2016 6:32 pm
by johnlong
But in problem it is assumed that default are applied.
At least I think so because JPA is mainly configuration by exception, is not it?

Re: About Question enthuware.oce-jpad.v6.2.462 :

Posted: Mon Dec 26, 2016 12:45 am
by admin
Unless it says so explicitly in any question you should not assume anything. For example, if a problem mentions an application exception without showing its complete code or without specifying that it has set rollback=false, you should not assume that it will not cause a transaction to roll back even though by default an application exception will not cause a transaction to rollback.

Re: About Question enthuware.oce-jpad.v6.2.462 :

Posted: Wed Dec 28, 2016 7:46 am
by johnlong
Thanks.

Re: About Question enthuware.oce-jpad.v6.2.462 :

Posted: Wed Jul 19, 2017 6:00 pm
by himaiMinh
Option "Retrieve the entity again using a query" is marked as wrong and explanation says : "JPA specification does not specify what happens to a managed entity if it is included in a result of a query. In many cases, the entity manager does not refresh the existing entity in the persistence context."
But on other hand JPA specification says that result of the query (in case of FlushModeType.AUTO) shall reflect current state, and should not return stale data.
With regard to this post, even though we set the query's flushModeType = AUTO, the query can "see" the changes in the pending transaction, but the query still cannot see the latest update in the database itself.
Correct me if I am wrong.