Read-Only Tracking Not Disabled (ARCH4054)
Ce contenu n’est pas encore disponible dans votre langue.
Key java.orm.readonly-tracking-not-disabled · Severity warning · Category orm
Loading data you only read as fully tracked (managed) entities needlessly bloats the persistence context. Enable read-only mode via @QueryHints for read-only queries.
Incorrect
Section titled “Incorrect”@Query("SELECT u FROM User u WHERE u.active = true")List<User> findActive(); // hydrates tracked entitiesCorrect
Section titled “Correct”@QueryHints(@QueryHint(name = HINT_READONLY, value = "true"))@Query("SELECT u FROM User u WHERE u.active = true")List<User> findActive();Disable tracking on non-writing queries with a read-only hint or a DTO projection.