Uploaded image for project: 'Spring Data JPA'
  1. Spring Data JPA
  2. DATAJPA-1555

InvalidDataAccessApiUsageException occurs when using @Procedure annotation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.1.8 (Lovelace SR8)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:

      Description

      I have an Entity class named 'Category' and trying use stored procedure based on the[ official docs |https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.stored-procedures]. 

       

      Category.Java

      @Entity
      @Data
      @EqualsAndHashCode(callSuper = true)
      @Table(name = "category")
      @NamedStoredProcedureQuery(name = "getAllCategoriesThroughStoredProcedure",procedureName = "get_all_categories",resultClasses = Category.class)
      public class Category extends AbstractAuditingEntity implements Serializable
      {
       private static final long serialVersionUID = -6699422774799518217L;
      
       @Id
       @Column(name = "id")
       @GeneratedValue(strategy = GenerationType.IDENTITY)
       private Long id;
      
       @NotEmpty
       @Column(name = "name", nullable = false)
       private String name;
      
      
       @Column(name = "description")
       private String description;
      
      }

       

      CategoryRepository.Java

      public interface CategoryRepository extends JpaRepository<Category,Long>
      {
      @Procedure(procedureName="get_all_categories")
      List<Category> getAllCategoriesThroughStoredProcedure();
      }
      
      

      When I invoke getAllCategoriesThroughStoredProcedure() method I get an exception

      org.springframework.dao.InvalidDataAccessApiUsageException: Type cannot be null; nested exception is java.lang.IllegalArgumentException: Type cannot be null]
       
      

       

      I tried different syntaxes specified on official docs and everything throws the same error. I am using spring-boot-starter-data-jpa:2.1.5.RELEASE with Spring Boot 2.1.5

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              schauder Jens Schauder
              Reporter:
              jpavanaryan@gmail.com Pavan Kumar Jadda
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: