An application creates a TypedQuery object to perform a query, and sets the query objects flush mode by calling setFlushMode (FlushModeType.commit). The query is executed within a transaction.
Which of the following is true?
A.
Updates to the database tables may occur anytime during the transaction associated with the query.
B.
Updates to the entities that can affect the outcome of the query cannot be flushed to the database until the transaction commits.
C.
Changes to the entities in this transaction cannot be flushed to the database until the transaction commits.
D.
setFlushMode cannot be called on a TypedQuery object.
A
B, A is incorrect
setFlushMode (FlushModeType.commit) means that no flush until the transaction commit.
A is correct
Flushing to occur at transaction commit. The provider may flush at other times, but is not required to.
https://docs.oracle.com/javaee/6/api/javax/persistence/FlushModeType.html#COMMIT
A
A
Correct answer is A.
According to the JPA specification (3.8.7 Queries and Flush Mode):
If FlushModeType.COMMIT is set, the effect of updates made to entities in the persistence
context upon queries is unspecified.