Select Star Over Fetch (ARCH4066)
هذا المحتوى غير متوفر بلغتك بعد.
Key java.orm.select-star-over-fetch · Severity info · Category orm
Fetching the full entity when only a few fields are used inflates row width and serialization cost. Use a DTO projection.
Incorrect
Section titled “Incorrect”@Query("SELECT u FROM User u") // all columnsList<User> findAll();
findAll().forEach(u -> emails.add(u.getEmail())); // only email neededCorrect
Section titled “Correct”@Query("SELECT new com.app.EmailView(u.id, u.email) FROM User u")List<EmailView> findEmails();Use a DTO/projection query that selects only the required fields.