新手请教个Mybatis的问题

mcrbaby 2015-09-08 10:31:24
在做一个项目,用到Mybatis,数据库是SQLServer2012,我用Mybatis调用存储过程,返回的是空结果集,求教大神帮忙解决下。
Mybatis是3.3.0,驱动是net.sourceforge.jtds.jdbc.Driver
mapper.xml中是这么写的:
<resultMap type="hashmap" id="testResult">
<id property="id" column="STK004OID"/>
<result property="GYS" column="GYS" />
<result property="PM" column="PM" />
<result property="SJKCSL" column="SJKCSL" />
<result property="XH" column="XH" />
<result property="GGXH" column="GGXH" />
<result property="XS" column="XS" />
<result property="RKRQ" column="RKRQ" />
<result property="DCDDH" column="DCDDH" />
<result property="PP" column="PP" />
<result property="CD" column="CD" />
<result property="CKMC" column="CKMC" />
</resultMap>
<parameterMap type="hashmap" id="testParameterMap">
<parameter property="result" jdbcType="OTHER" resultMap="testResult" mode="OUT" javaType="java.sql.ResultSet"/>
<parameter property="PartnerID" jdbcType="VARCHAR" mode="IN"/>
<parameter property="FSNO" jdbcType="VARCHAR" mode="IN"/>
<parameter property="S_Date" jdbcType="DATE" mode="IN"/>
<parameter property="E_Date" jdbcType="DATE" mode="IN"/>
<parameter property="Spec" jdbcType="VARCHAR" mode="IN"/>
</parameterMap>

<select id="getCKPOInfo" parameterMap="testParameterMap" resultMap="testResult" statementType="CALLABLE">
{#{result} = call PR_B2BShipmentDs(#{PartnerID},#{FSNO},#{S_Date},#{E_Date},#{Spec})}
</select>

JAVA代码 :
String resource = "mybatis/configuration/erp_conf.xml";
//构建sqlSession的工厂
//使用MyBatis提供的Resources类加载mybatis的配置文件(它也加载关联的映射文件)
Reader reader = Resources.getResourceAsReader(resource);
//构建sqlSession的工厂
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
//创建能执行映射文件中sql的sqlSession
SqlSession session = sessionFactory.openSession();
Map<String,Object> paraMap = new HashMap<String,Object>();
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

paraMap.put("PartnerID", "T00040-C");
paraMap.put("FSNO", null);
paraMap.put("S_Date", sdf.parse("1999-01-01"));
paraMap.put("E_Date", sdf.parse("2050-01-01"));
paraMap.put("Spec", null);

List<TestBO> list = session.selectList(sql, paraMap);
System.out.println("0>>>>>>>>>::"+list.size());
} catch (ParseException e) {
e.printStackTrace();
}
session.close();
打印的list.size()为0,求大神指导是什么情况,数据库中是有数据的
...全文
119 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mcrbaby 2015-09-08
  • 打赏
  • 举报
回复
上面存储过程中是没有@Res varchar(max) output 这个参数的,是我自己测试写了个 忘记删掉了
mcrbaby 2015-09-08
  • 打赏
  • 举报
回复
附上存储过程 USE [fusenTarget0401] GO /****** Object: StoredProcedure [dbo].[PR_B2BShipmentDs] Script Date: 2015/9/2 15:38:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[PR_B2BShipmentDs] @FSNO VARCHAR(50), @S_Date datetime, --出库开始日期 @E_Date datetime, --出库结束日期 @Spec varchar(50), --型号 @PartnerID varchar(50) ,--客户 @Res varchar(max) output as SET @S_Date=ISNULL(@S_Date,'2000-1-1') SET @E_Date=ISNULL(@E_Date,'2099-1-1') SET @E_Date=DATEADD(DD,1,@E_Date) SELECT STK004.STK004OID, --库存主键 STK004.VendorName AS GYS, --供应商 STK004.TradeName as PM,--品名 STK004.Spec as XH,--规格型号 STK004.Qty as SJKCSL,--数量 STK004.CartonNO as XH,--箱号 CASE WHEN LEN(STK004.CartonNO)<=8 THEN 1 ELSE 0 END XS,--箱数 STK004.MixedPackaged as XDXH,--一箱多型号 STK004.OrgCartonNO as YXH,--原箱号 STK004.S_Times as CXCS,--拆箱次数 STK004.Refno as RKDH,--入库单号 STK004.SAreaID as CWBM,--储位编号 CONVERT(varchar(50),STK004.InDate, 20) as RKRQ,--入库日期 STK004.Col1 as BS1, --标识1 STK004.Col2 as BS2, --标识2 STK004.Col3 as BS3, --标识3 STK004.Col4 as BS4, --标识4 STK004.Col5 as BS5, --标识5 STK004.STKStatus as KCZT,--库存状态 STK004.INDocno as RKDH2,--入库单号 STK004.PONO as DCDDH,--采购单号 STK004.Currency as BB,--币别 STK004.Price as DJ,--单价 STK004.Brand as PP,--品牌 STK004.Original as CD,--产地 STK004.GrossWeight as MZ,--毛重 STK004.NetWeight as JZ,--净重 STK004.Length as L,--长 STK004.Width as K,--宽 STK004.Height as G,--高 STK004.CBM as CBM,--CBM alBASB001_FK.PartnerShortName AS KH,--客户 STK004.JNCartonNO as JNXH,--JN箱号 (SELECT top 1 T1.Docno FROM STK010 T1 INNER JOIN STK010D1 T2 ON T1.STK010OID=T2.STK010_FK WHERE T2.STK004_FK=STK004OID) as CKDH,--出库单号 alSHA001_FK.FSMessage AS DDXX,--订单信息 BASA013.WarehouseName AS CKMC,--仓库名称 STK004.IS_Lock --是否锁定 FROM STK004 LEFT OUTER JOIN BASB001 alBASB001_FK ON STK004.BASB001_FK= alBASB001_FK.BASB001OID LEFT OUTER JOIN SHA001 alSHA001_FK ON STK004.SHA001_FK= alSHA001_FK.SHA001OID left outer join BASA013 on STK004.BASA013_FK=BASA013.BASA013OID where STK004.IS_Lock=0 and (STK004.PONO like'%'+@FSNO+'%' or isnull(@FSNO,'')='') and STK004.InDate>=@S_Date AND STK004.InDate<@E_Date and ( STK004.Spec like'%'+@Spec+'%' or isnull(@Spec,'')='') and alBASB001_FK.PartnerID=@PartnerID
mcrbaby 2015-09-08
  • 打赏
  • 举报
回复
有哪位大神来解答下吗?为什么返回的是空结果集,而我在SQLServer中执行该存储过程是有结果集的

50,451

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧