2016-04-27 63 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参数索引超出的范围“