关于mybatis调用mysql存储过程,得到空值,求帮助

v_Cloud 2017-10-27 05:23:46
Dao层:

int instertUserWeight(@Param("_uid") Integer uid,@Param("_gid") Integer gid,@Param("_count") Long count,@Param("_result") Integer result);

Mapping层:

<select id="instertUserWeight" parameterType="map" statementType="CALLABLE" resultMap="BaseResultMap">
{CALL proc_BetWeightSave(
#{_uid,mode=IN,jdbcType=INTEGER},
#{_gid,mode=IN,jdbcType=INTEGER},
#{_count,mode=IN,jdbcType=BIGINT},
#{_result,mode=OUT,jdbcType=INTEGER}
)}
</select>

存储过程:

运行结果为2, 传入值1,1,@result
但是用mybatis调用的时候拿到的是空值,求帮助
...全文
248 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
这是一款轻量级的MyBatis插件,在GitHub上发布的有打好的jar包,25.2Kb,导入项目中即可使用,支持创建数据表、自定义查询、分页查询等常用的数据库操作。 依赖包 org.mybatis.spring.boot mybatis-spring-boot-starter 1.3.2 mysql mysql-connector-java runtime 目录结构 mybatisMyBatis 通用 Mapper 相关 annotation:注解相关 FieldAttribute.java:字段注解,标示成员变量为数据库字段,并设置相应的约束信息,如:长度、非空、查询字段、索引字段等 KeyAttribute.java:主键注解,标示成员变量为主键,支持标注为自增主键 SortAttribute.java:排序注解,标示成员变量为排序字段 TableAttribute.java:数据表注解,标示实体类对应的表名称、说明信息 provider:Sql 语句生成相关 BaseCreateProvider.java:数据表创建语句的生成器,支持生成索引 BaseDeleteProvider.java:delete 语句生成器,支持根据 ID、主键、自定义条件删除 BaseInsertProvider.java:insert 语句生成器,支持自增主键的 insert 操作 BaseSelectProvider.java:select 语句生成器,支持分页查询、统计查询、自定义条件查询等 BaseUpdateProvider.java:update 语句生成器,支持根据 ID、主键修改数据 BaseEntity.java:所有实体类的父类,提供了自定义查询条件、分页查询、排序的扩展 BaseException.java:自定义异常,在通用 Mapper 运行过程中抛出的异常 BaseMapper.java:所有 Mapper 的父类,提供了通用 Mapper 功能 SqlFieldReader.java:Sql 字段解析类,用于解析实体类中的自定义注解,为生成 Sql 语句服务 TypeCaster.java:类型转换,用于将 Java 中的数据类型转换成相应的 MySql 数据类型 util:工具类相关 Console.java:日志输出工具类,用于在控制台、日志文件中输出相关信息 ObjectUtils.java:Object 工具类,用于对象的空值判断 StringUtils.java:字符串工具类,用于生成指定格式的字符串及对字符串进行各种处理 使用方式 实体类继承 BaseEntity 并使用注解 @TableAttribute(name = "user_info",comment = "用户信息表") public class UserInfo extends BaseEntity { // 标注是自增主键 @KeyAttribute(autoIncr = true) // 标注是数据库字段 @FieldAttribute private int id; // 设置字段注释、非空约束、作为查询条件 @FieldAttribute(value = "用户类型",notNull = true,isCondition = true) private Integer type; @FieldAttribute(value = "密码",length = 200, isDetailed = true) private String password; // 设置字段注释、非空约束、字段长度、是索引字段 @FieldAttribute(value = "邮箱",notNull = true,length = 200,isIndex = true) private String email; @FieldAttribute @SortAttrtibute private Date createTime = new Date(); @FieldAttribute(value = "用户账号状态",isCondition = true) private Integer status ; @FieldAttribute(value = "是否删除,1 表示删除",isCondition = true) private Integer isDelete; ... ... } Dao 层继承 BaseMapper @Mapper public interface UserMapper extends BaseMapper { } 调用 /** * 根据类型和邮箱查询用户 * @param type * @param email * @return */ private UserInfo getByEmailAndType(int type,String email){ UserInfo userInfo = new UserInfo(); // 设置查询条件1 Email userInfo.setEmail(email); // 设置查询条件2 Type userInfo.setType(type); // 设置使用 And 连接多个查询条件 userInfo.setBaseKyleUseAnd(true); // 执行查询并返回结果 List list = userMapper.baseSelectList(userInfo); if(list != null && list.size() > 0){ return list.get(0); } return null; }

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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