2016-04-27 34 views
0

Ich habe eine gespeicherte Prozedur mit der folgenden Erklärung:Spring Data und gespeicherte Prozeduren

CREATE PROCEDURE GetAttributesForCategory(IN catId BIGINT(20)) 

In meinem Frühling Stiefel -backed App gibt es eine Einheit:

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

Und der Korrespondent Repository sieht so aus:

public interface ProductAttributeReposirory extends JpaRepository<ProductAttribute, Long> { 

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

Alles ist nach t gemacht o this example, aber eine Ausnahme im Frühjahr Kontext Laden aufgetreten:

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! 

Ich kann mich nicht vorstellen, was schief geht. Jeder kann?

Antwort

0

Ich war mit diesem das gleiche Problem haben, und beschlossen, sie durch eine OUT @StoredProcedureParameter Zugabe:

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

an dieser Stelle, obwohl ich einen anderen Fehler „Parameterindex von 2 bin immer aus ist des Bereichs "