2016-04-27 24 views
0

我有如下聲明一個存儲過程:春數據和存儲過程

CREATE PROCEDURE GetAttributesForCategory(IN catId BIGINT(20)) 

在我春天引導 -backed應用程序有一個實體:

@Entity 
@NamedStoredProcedureQueries({ 
     @NamedStoredProcedureQuery(
       name = "ProductAttribute.getAttributesForCategory", 
       procedureName = "GetAttributesForCategory", 
       parameters = { 
         @StoredProcedureParameter(name = "catId", 
                type = Long.class, 
                mode = ParameterMode.IN) 
       } 
     ) 
}) 
public class ProductAttribute { 
    ... 
} 

和記者資料庫看起來像:

public interface ProductAttributeReposirory extends JpaRepository<ProductAttribute, Long> { 

    @Procedure(name = "getAttributesForCategory") 
    List<ProductAttribute> getAttributesForCategory(@Param("catId") Long catId); 
} 

所有是根據t Øthis example,但Spring上下文加載過程中發生了異常:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'productAttributeRepository': Invocation of init method failed; 
nested exception is org.springframework.data.mapping.PropertyReferenceException: 
No property getAttributesForCategory found for type ProductAttribute! 

我不能想象什麼不順心。任何人都可以?

回答

0

我是有這個相同的問題,並通過添加OUT @StoredProcedureParameter解決它:

@StoredProcedureParameter(mode = ParameterMode.IN, name = "inVar", type = String.class), @StoredProcedureParameter(mode = ParameterMode.OUT, name = "outVar", type = ArrayList.class)

雖然在這一點上,我得到一個不同的錯誤「的2參數索引超出的範圍「