问题描述
CREATE PROCEDURE [dbo].[createSession]
@token nvarchar(max) = '',@user nvarchar(max) = '',@password nvarchar(max) = '',@sessionUid nvarchar(max)= null out
AS
BEGIN ...
使用sql,我可以这样称呼它:
exec createSession
@password= 'pass',@user = 'user',@sessionUid = @sessionUid out
请注意,令牌是可选的,因此我不必指定它(也不需要)。而且由于使用命名参数,所以可以指定与存储过程中定义的顺序不同的顺序。
当我从应用程序拨打电话时:
@Entity
@NamedStoredProcedureQuery(name = "session",procedureName = "createSession",parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN,name = "user",type = String.class),@StoredProcedureParameter(mode = ParameterMode.IN,name = "password",@StoredProcedureParameter(mode = ParameterMode.OUT,name = "sessionUid",type = String.class) })
public class Session { ... }
public interface SessionRepo extends Repository<Session,String> {
@Procedure(name="session",outputParameterName="SessionUid")
String getSession(@Param("user") String user,@Param("password") String password);
我收到一条错误消息,指出“索引4超出范围”。
如果我将token
添加到@NamedStoredProcedureQuery
和getSession
方法中,则可以正常工作。但是实际的存储过程createSession
包含许多可选参数。有没有一种方法可以仅使用我要为其指定值的参数来调用存储过程?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)