A developer wants to ensure that an entity’s data is up-to-date with regard to the database.
Which of the following statements is guaranteed to accomplish this?
A.
Call EntityManager.refresh on the entity.
B.
Add acacheable (false) annotation on the entity class.
C.
Call EntityManager.find on the entity.
D.
Use a named query to retrieve the entity.
A
A
void refresh(java.lang.Object entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
See http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html
A
Answer A
T find(java.lang.Class entityClass,
java.lang.Object primaryKey)
Find by primary key. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence context, it is returned from there.