lsp4jakarta icon indicating copy to clipboard operation
lsp4jakarta copied to clipboard

JEE11_Data: The signature of a method annotated with @Delete must clearly indicate whether deletion is by entity, by ID, or by condition.

Open archana-1924 opened this issue 1 month ago • 0 comments

Description:

  • The signature of a repository method annotated @Delete must be used to disambiguate the interpretation of the @Delete annotation.
  • A repository method annotated with @Delete may have multiple possible interpretations (e.g., delete by entity, delete by ID, delete by condition).
  • The method signature (parameter type, return type, modifiers) must be used to disambiguate how the @Delete annotation is applied.

Examples:

Invalid example 1

public interface ProductRepository extends CrudRepository<Product, Long> { 
    @Delete 
    void remove(Object obj);  
    //Invalid: ambiguous parameter type, cannot disambiguate entity vs ID 
} 

Invalid example 2

public interface ProductRepository extends CrudRepository<Product, Long> { 
    @Delete 
    Product removeById(long id);  
    //Invalid: return type suggests entity, but signature implies delete by ID 
} 

Valid example 1

public interface ProductRepository extends CrudRepository<Product, Long> { 
    @Delete 
    void remove(Product product);  
    // Signature indicates deletion by entity 
} 

Valid example 2

public interface ProductRepository extends CrudRepository<Product, Long> { 
    @Delete 
    void removeById(long id);  
    //Signature indicates deletion by ID 
} 

Valid example 3

public interface ProductRepository extends CrudRepository<Product, Long> { 
    @Delete 
    long removeByCategory(String category);  
    //Signature indicates deletion by condition, returning count of deleted rows 
} 

Specification: 

https://jakarta.ee/specifications/data/1.0/jakarta-data-1.0#:~:text=The%20signature%20of%20a%20repository%20method%20annotated%20%40Delete%20must%20be%20used%20to%20disambiguate%20the%20interpretation%20of%20the%20%40Delete%20annotation.

Type of language feature proposed:

Select all that apply

  • [x] diagnostic
  • [ ] quick-fix
  • [ ] snippet
  • [ ] other, please specify:

archana-1924 avatar Nov 21 '25 04:11 archana-1924