The Java Persistence API defines the Query interface. Which two statements about the Query.executeUpdate method are true? (Choose two)
- It must always be executed within a transaction
- It throws a PersistenceException if no entities were updated
- It throws an IllegalStateException if called on a Query instance created with a Java Persistence SELECT query
- All managed entity objects corresponding to database rows affected by the update will have their state changed to correspond with the update
El método executeUpdate de la interfaz Query ejecuta una sentencia update o delete. Retorna el número de entidades actualizadas o eliminadas y lanza la excepción IllegalStateException si es invocado para una sentencia SELECT. En caso no se ejecute dentro de una transacción, se lanza TransactionRequiredException.
Entonces, las alternativas correctas son la primera y la tercera.
Pregunta tomada de ExamWorx
Publicar un comentario