postgresql - Spring @Procedure and List as return -
anyone know how use @procedure spring annotation postgres procedure (function) returns setof?
the code below not work:
public interface calculatedeventrepository extends crudrepository<calculatedevent, calculatedeventid> { @procedure(name = 'calculatedevent.calculate') list<calculatedevent> calcular(@param("yearmonth") integer yearmonth) }
entity
@entity @namedstoredprocedurequery(name = 'calculatedevent.calculate', procedurename = 'fn_calcula_eventos', resultclasses = calculatedevent.class, parameters = [ @storedprocedureparameter( mode = parametermode.in, name = 'yearmonth', type = integer.class), @storedprocedureparameter(mode = parametermode.out, name = 'res', type = list.class) ] ) public class calculatedevent implements serializable { ... }
however have following exception:
java.lang.illegalargumentexception: type cannot null org.hibernate.procedure.internal.abstractparameterregistrationimpl.sethibernatetype(abstractparameterregistrationimpl.java:182) org.hibernate.procedure.internal.abstractparameterregistrationimpl.<init>(abstractparameterregistrationimpl.java:131) org.hibernate.procedure.internal.abstractparameterregistrationimpl.<init>(abstractparameterregistrationimpl.java:106) org.hibernate.procedure.internal.namedparameterregistration.<init>(namedparameterregistration.java:50) org.hibernate.procedure.internal.procedurecallimpl.<init>(procedurecallimpl.java:221) org.hibernate.procedure.internal.procedurecallmementoimpl.makeprocedurecall(procedurecallmementoimpl.java:83) org.hibernate.jpa.internal.storedprocedurequeryimpl.<init>(storedprocedurequeryimpl.java:80) org.hibernate.jpa.spi.abstractentitymanagerimpl.createnamedstoredprocedurequery(abstractentitymanagerimpl.java:982) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:483) org.springframework.orm.jpa.extendedentitymanagercreator$extendedentitymanagerinvocationhandler.invoke(extendedentitymanagercreator.java:344) com.sun.proxy.$proxy70.createnamedstoredprocedurequery(unknown source) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:483) org.springframework.orm.jpa.sharedentitymanagercreator$sharedentitymanagerinvocationhandler.invoke(sharedentitymanagercreator.java:291) com.sun.proxy.$proxy70.createnamedstoredprocedurequery(unknown source) org.springframework.data.jpa.repository.query.storedprocedurejpaquery.newnamedstoredprocedurequery(storedprocedurejpaquery.java:119) org.springframework.data.jpa.repository.query.storedprocedurejpaquery.createstoredprocedure(storedprocedurejpaquery.java:109) org.springframework.data.jpa.repository.query.storedprocedurejpaquery.docreatequery(storedprocedurejpaquery.java:68) org.springframework.data.jpa.repository.query.storedprocedurejpaquery.createquery(storedprocedurejpaquery.java:58) org.springframework.data.jpa.repository.query.jpaqueryexecution$procedureexecution.doexecute(jpaqueryexecution.java:295) org.springframework.data.jpa.repository.query.jpaqueryexecution.execute(jpaqueryexecution.java:74) org.springframework.data.jpa.repository.query.abstractjpaquery.doexecute(abstractjpaquery.java:97) org.springframework.data.jpa.repository.query.abstractjpaquery.execute(abstractjpaquery.java:88) org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.doinvoke(repositoryfactorysupport.java:395) org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:373) org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) org.springframework.data.repository.core.support.repositoryfactorysupport$defaultmethodinvokingmethodinterceptor.invoke(repositoryfactorysupport.java:486) org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:99) org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:281) org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:96) org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:136) org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) org.springframework.data.jpa.repository.support.crudmethodmetadatapostprocessor$crudmethodmetadatapopulatingmethodintercceptor.invoke(crudmethodmetadatapostprocessor.java:122) org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:92) org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) com.sun.proxy.$proxy73.calcular(unknown source) br.com.well.coney.persistence.repository.calculatedeventrepository$calcular.call(unknown source) org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:108) org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:116) br.com.well.coney.application.implementation.calculatedeventserviceimpl.calculateincludes(calculatedeventserviceimpl.groovy:80) br.com.well.coney.application.implementation.calculatedeventserviceimpl.this$2$calculateincludes(calculatedeventserviceimpl.groovy) br.com.well.coney.application.implementation.calculatedeventserviceimpl$this$2$calculateincludes.callcurrent(unknown source) org.codehaus.groovy.runtime.callsite.callsitearray.defaultcallcurrent(callsitearray.java:49) org.codehaus.groovy.runtime.callsite.abstractcallsite.callcurrent(abstractcallsite.java:133) org.codehaus.groovy.runtime.callsite.abstractcallsite.callcurrent(abstractcallsite.java:145) br.com.well.coney.application.implementation.calculatedeventserviceimpl.calculate(calculatedeventserviceimpl.groovy:22) br.com.well.coney.application.calculatedeventservice$calculate.call(unknown source) org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:108) org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:116) br.com.well.coney.application.remote.chartresource.getexpenses(chartresource.groovy:71) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:483) org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137) org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:777) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:706) org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:943) org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877) org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966) org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857) javax.servlet.http.httpservlet.service(httpservlet.java:618) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842) javax.servlet.http.httpservlet.service(httpservlet.java:725) org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330) org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118) org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:154) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:199) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:110) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.csrf.csrffilter.dofilterinternal(csrffilter.java:85) org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.header.headerwriterfilter.dofilterinternal(headerwriterfilter.java:57) org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:50) org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192) org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160) org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:344) org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:261)
ps.: function works fine on database.
this reported bug https://jira.spring.io/browse/datajpa-652.
i struggled same issue find out there's nothing do. can try switch eclipselink. link above mentions sample: https://gist.github.com/thomasdarimont/129bc15d0ccc459610c2.