Results 1 to 1 of 1
- 12-15-2009, 06:07 PM #1Member
- Join Date
- Oct 2009
- Rep Power
EntityManager.setFlushMode(COMMIT) Vs. Query.setFlushMode(COMMIT)
[P-331 of EJB3 In Action Book] states:
"By default, the database flush mode is set to AUTO. This means that the Entity-Manager performs a flush operation automatically as needed.
In general, this occurs at the end of a transaction for transaction-scoped EntityManagers and when the persistence context is closed for
application-managed or extendedscope EntityManagers. In addition, if entities with pending changes are used in a query, the persistence
provider will flush changes to the database before executing the query.If the flush mode is set to COMMIT, the persistence provider will
only synchronize with the database when the transaction commits.However, you should be careful with this, as it will be your responsibility
to synchronize entity state with the database before executing a query. If you donít do this and an EntityManager query returns stale
entities from the database, the application can wind up in an inconsistent state."
[P-353 EJB3 In Action Book] states:
"If the Query is set to FlushModeType.COMMIT, the effect of updates made to entities in the persistence context is not defined
by the specification, and the actual behavior is implementation specific".
So setting the flush mode as COMMIT on EntityManager and Query have different results..Right ??
- By swati.jyoti in forum NetBeansReplies: 1Last Post: 07-24-2009, 06:33 PM
- By dilipg003 in forum EclipseReplies: 2Last Post: 05-12-2009, 07:17 PM
- By Cold-Gin in forum EclipseReplies: 1Last Post: 04-09-2009, 11:49 PM
- By amt_asc in forum JDBCReplies: 1Last Post: 04-03-2009, 03:25 PM
- By egc_33 in forum EclipseReplies: 0Last Post: 08-09-2008, 03:27 PM