博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用mybatis的时候,实体类字段基本类型最好是包装类
阅读量:2351 次
发布时间:2019-05-10

本文共 553 字,大约阅读时间需要 1 分钟。

 

用mybatis的时候,实体类字段基本类型最好是包装类,最好不要设置默认值,否则 xml 里处理会很尴尬。

 

如果出现这种情况了,实体类里建一个设置初始值为null 的构造函数。

 

 

package com.bugyun.test;public class Student {	/**	 * 这两个字段最好不要设置初始值	 */	private Integer  id = 0;	private Integer clzssId = 0 ;	/**	 * 如果设置初始值了,建议用置空的构造函数	 */	public Student(Integer id, Integer clzssId) {		super();		this.id = null;		this.clzssId = null;	}		public Integer getId() {		return id;	}	public void setId(Integer id) {		this.id = id;	}	public Integer getClzssId() {		return clzssId;	}	public void setClzssId(Integer clzssId) {		this.clzssId = clzssId;	}	}

 

转载地址:http://irevb.baihongyu.com/

你可能感兴趣的文章
Box2d no gravity
查看>>
mario collision
查看>>
spring boot日志配置
查看>>
list排序
查看>>
1005. 数独
查看>>
IDE配置jvm参数
查看>>
内存溢出
查看>>
Spring Cloud 声明式服务调用 Feign
查看>>
我要学ASP.NET MVC 3.0(十): MVC 3.0 使用 Forms身份验证
查看>>
我要学ASP.NET MVC 3.0(十四): MVC 3.0 实例系列之创建数据表格
查看>>
我要学ASP.NET MVC 3.0(十五): MVC 3.0 实例系列之表格的排序
查看>>
HTTP触发Jenkins参数化构建(CORS Plugin)
查看>>
ubuntu12.04--子进程 已安装 post-installation 脚本 返回了错误号 1
查看>>
系统--电脑开机一声长响
查看>>
系统--A disk read error occurred Press Ctrl+Alt+d...
查看>>
Some projects cannot be imported because they a...
查看>>
ubuntu-android--make: *** [out/host/linux-x86/o...
查看>>
2--第四层
查看>>
3--TCP三次握手
查看>>
4--网关
查看>>