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

Moderator: admin

Post Reply
johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post 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.

admin
Site Admin
Posts: 8910
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Right, but that is only in the case of in case of FlushModeType.AUTO.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post 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?

admin
Site Admin
Posts: 8910
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Thanks.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest