Announcement Announcement Module
Collapse
No announcement yet.
using spring data jpa to access stored procedure with multiple out params Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using spring data jpa to access stored procedure with multiple out params

    I have a legacy application that I am migrating to use spring-data-jpa that is using stored procedures to access all the data. I do not have direct table access so all of my entities will use stored procedures.

    When I try to run a unit test to prove that this will work, I get the following exception.

    Caused by: org.springframework.data.mapping.PropertyReference Exception: No property get found for type Account!

    I'm not really sure what spring-data will return with the multiple out parameters so for now, I am returning an Object.

    The entity class is annotated with the stored procedure.
    Code:
    @Entity
    @NamedStoredProcedureQuery(name = "getAccountInfo", procedureName = "CIS_V.ACCOUNT_INFO", parameters = {
            @StoredProcedureParameter(name = "sourceId", mode = ParameterMode.IN, type = String.class),
            @StoredProcedureParameter(name = "companyId", mode = ParameterMode.IN, type = Integer.class),
            @StoredProcedureParameter(name = "accountNbr", mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(name = "returnCode", mode = ParameterMode.OUT, type = Integer.class),
            @StoredProcedureParameter(name = "errorMessageId", mode = ParameterMode.OUT, type = Integer.class),
            @StoredProcedureParameter(name = "errorMessage", mode = ParameterMode.OUT, type = String.class),
            @StoredProcedureParameter(name = "data", mode = ParameterMode.OUT, type = Object.class), })
    public class Account implements Serializable {
    The repository class is annotated to use the @Procedure
    Code:
    @Repository
    public interface AccountRepository extends CrudRepository<Account, Long> {
    
        @Procedure(name = "getAccountInfo")
        Object getAccountInfo(String sourceId, int companyId, long accountId);
    
    }
    I am using spring 4.0.3 with spring-data-jpa 1.6

    The full stack trace is:

    Code:
    Caused by: org.springframework.data.mapping.PropertyReferenceException: No property get found for type Account!
        at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:359) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:359) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:213) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:321) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:301) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:82) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:60) ~[spring-data-jpa-1.6.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:91) ~[spring-data-jpa-1.6.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:168) ~[spring-data-jpa-1.6.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:69) ~[spring-data-jpa-1.6.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:320) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:169) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) ~[spring-data-jpa-1.6.0.RELEASE.jar:na]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571) ~[spring-beans-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509) ~[spring-beans-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        ... 38 common frames omitted
Working...
X