Quizzes@Auditing with Spring Data — Concept Check
intermediate
hibernate

@Auditing with Spring Data — Concept Check

Questions on @Auditing with Spring Data. Enable @EnableJpaAuditing and annotate fields with @CreatedDate, @LastModifiedDate, @CreatedBy, @LastModifiedBy; an AuditorAware bean supplies the current user identity.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on @Auditing with Spring Data — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer has enabled @EnableJpaAuditing but notices that the @CreatedDate field is not being populated. What could be the issue?

    • AThe AuditorAware bean is not defined.
    • BThe @CreatedDate annotation is used incorrectly.
    • CThe entity is missing @EntityListeners(AuditingEntityListener.class).
    • D@EnableJpaAuditing should not be used in a @Configuration class.
  2. 2.An entity's @LastModifiedBy field is always null after updates. What might be the cause?

    • A@LastModifiedBy is not supported in Spring Data JPA.
    • BThe @LastModifiedBy annotation is used incorrectly.
    • CThe AuditorAware bean is not correctly implemented.
    • DThe entity is missing the @MappedSuperclass annotation.
  3. 3.A developer uses Hibernate Envers for audit history but notices some fields are not tracked. Why?

    • AHibernate Envers does not support tracking all fields.
    • BThe fields are not part of the entity.
    • C@Audited annotation is missing on the entity.
    • DThe fields are annotated with @NotAudited.
  4. 4.Which annotation ensures that an entity's creation and modification timestamps are automatically populated?

    • A@EnableJpaAuditing
    • B@Audited
    • C@EntityListeners(AuditingEntityListener.class)
    • D@MappedSuperclass
  5. 5.A system user is performing batch jobs, but the @CreatedBy field is not populated. What could resolve this?

    • AManually set the @CreatedBy field in the code.
    • BEnable @EnableJpaAuditing in a different class.
    • CUse a FallbackAuditorAware to provide a default user.
    • DEnsure @CreatedBy is correctly annotated.
  6. 6.A developer claims that enabling @EnableJpaAuditing automatically tracks full audit history. Is this correct?

    • AYes, it tracks all changes by default.
    • BNo, it only tracks the latest state.
    • CNo, it requires additional configuration with Hibernate Envers.
    • DYes, but only for entities with @Audited.
  7. 7.Why might the @CreatedBy field remain empty even when a user is authenticated?

    • AThe AuditorAware bean returns an empty Optional.
    • BThe entity is not annotated with @Entity.
    • C@CreatedBy is not supported for authenticated users.
    • D@CreatedBy is incorrectly placed on a non-entity field.