Open alterhu2020 opened 7 years ago
query.setParameter(1, userId); query.setParameter(2, password); setParameter(1,*); needs to be altered to(1, userName); for clarification purpose
Is this even possible at all without using EM directly?
@alterhu2020 you managed to solve it with @procedure ??
no @alanhugo , Need team provide the solution .... :(
Same issues here. Is it going to be solved anytime soon? Or any workarounds?
Any updates on this?
Not when someone finds time to properly address this. In the meantime: I did some experimenting with SP a while back. The resulting repo might be of some use (it's Oracle base though): https://github.com/schauder/calling-oracle-stored-procedures-with-cursors
I investigated this a bit and looks like currently Spring Data does not support returning a ResultSets from a stored procedure.
It all starts with the absence of OUT parameter which causes the following exception in StoredProcedureAttributeSource:
which causes to fallback createStrategy in JpaQueryLookupStrategy:
which ends up with the exception in this issue: No property renameMethodName found for type User!
So, if I understand the behavior correctly, we should not fallback to createStrategy in this case. Therefore, we need to change the condition in StoredProcedureAttributeSource, like:
if (outputParameters.size() > 1 && !void.class.equals(method.getReturnType())) {
This will help us to bypass the current exception but there will be other problems after executing stored procedure and extracting the output.
The reason is that:
In here, we have correct outputParameterType after changing the condition as I described above but outputParameterName is still null which causes the wrong decision here:
POSSIBLE WORKAROUND. http://stevenhorvatin.com/2016/09/30/how-to-call-a-stored-procedure-with-spring-boot-using-jpahibernate/
I found the same problem today (in fact looking for a solution brings me here), and this article from this guy helps me a lot to get many results from a store procedure and map them to an object with Spring boot.
You have to use the @entitymanager, I know!, it's not the fashion way, but I haven't found yet any solution using the crudrepository or repository interfaces from spring, and it resolve the problem.
have you tried to look at this
https://www.logicbig.com/tutorials/spring-framework/spring-data/stored-procedure-ref-cursor.html
The question is could your team add the example how to return the store procedure's result set not the output parameter we defined ? i can see we can return the output parameter as we define in the store procedure ,but I had not saw anywhere we can return the entity result list ,
My JPA annotation as below:
in my JPA repository i use below method to invoke the store procedure ,but it not worked:
Then run the code the error it throws as following:
and if I changed the
List<User>
tovoid
,the store procedure can invoked success ,but i want to return the result set from this store procedure,not just call the store procedure.And I also try to get the store procedure's result set just use the entitymanager directly, then we can get the mapped result list successfully ,see below:
It seems that Spring Data JPA only capable of handling a single value returned from a stored procedure? This issue really bothered me for too many days ...:( Please anyone help me how to get the store procedure's result set list from the annotation
@Procedure
in spring data jpa ? really thanks for your help very much .