求指导:MiniDao查询数据库返回映射

J2EE 码拜 8年前 (2016-09-23) 2488次浏览
求指导:MiniDao查询数据库返回映射

package org.jeecgframework.web.pcadmin.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.jeecgframework.core.util.StringUtil;
@Entity
@Table(name = "share_holder", schema = "")
@DynamicUpdate(true)
@DynamicInsert(true)
public class ShareHolder implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer holderId;//股东ID
	private String holderLoginname;//登录名
	private String holderName;//股东姓名
	private String holderStatusId;//股东身份证
	private String holderPhonenumber;//股东联系电话
	private String holderRecommendCode;//推荐码
	private Integer holderState;//状态(1启用 0禁用)
	private String holderEstablishDate;//创建时间
	private Integer holderRepresentative;//能否代表公司
	private String holderUsername;
	private String holderPassword;
	private String holderPosition;
	private String holderBonus;
	private String holderMygoal;
	private Integer manageId;
	private String holderMygoalDate;


	@Id
	@GeneratedValue
	@Column(name = "holder_id", nullable = false, length = 32)
	public Integer getHolderId() {
		return holderId;
	}
	public void setHolderId(Integer holderId) {
		this.holderId = holderId;
	}
	@Column(name = "holder_login_name")
	public String getHolderLoginname() {
		return holderLoginname;
	}
	public void setHolderLoginname(String holderLoginname) {
		this.holderLoginname = holderLoginname;
	}
	@Column(name = "holder_name")
	public String getHolderName() {
		return holderName;
	}
	public void setHolderName(String holderName) {
		this.holderName = holderName;
	}
	@Column(name = "holder_status_id")
	public String getHolderStatusId() {
		return holderStatusId;
	}
	public void setHolderStatusId(String holderStatusId) {
		this.holderStatusId = holderStatusId;
	}
	@Column(name = "holder_phone_number")
	public String getHolderPhonenumber() {
		return holderPhonenumber;
	}
	public void setHolderPhonenumber(String holderPhonenumber) {
		this.holderPhonenumber = holderPhonenumber;
	}
	@Column(name = "holder_recommend_code")
	public String getHolderRecommendCode() {
		return holderRecommendCode;
	}
	public void setHolderRecommendCode(String holderRecommendCode) {
		this.holderRecommendCode = holderRecommendCode;
	}
	@Column(name = "holder_state")
	public Integer getHolderState() {
		return holderState;
	}
	public void setHolderState(Integer holderState) {
		this.holderState = holderState;
	}
	@Column(name = "holder_establish_date")
	public String getHolderEstablishDate() {
		return holderEstablishDate;
	}
	public void setHolderEstablishDate(String holderEstablishDate) {
		this.holderEstablishDate = holderEstablishDate;
	}
	@Column(name = "holder_representative")
	public Integer getHolderRepresentative() {
		return holderRepresentative;
	}
	public void setHolderRepresentative(Integer holderRepresentative) {
		this.holderRepresentative = holderRepresentative;
	}
	@Column(name = "holder_username")
	public String getHolderUsername() {
		return holderUsername;
	}
	public void setHolderUsername(String holderUsername) {
		this.holderUsername = holderUsername;
	}
	@Column(name = "holder_password")
	public String getHolderPassword() {
		return holderPassword;
	}
	public void setHolderPassword(String holderPassword) {
		this.holderPassword = holderPassword;
	}
	@Column(name = "holder_position")
	public String getHolderPosition() {
		return holderPosition;
	}
	public void setHolderPosition(String holderPosition) {
		this.holderPosition = holderPosition;
	}
	@Column(name = "holder_bonus")
	public String getHolderBonus() {
		return holderBonus;
	}
	public void setHolderBonus(String holderBonus) {
		this.holderBonus = holderBonus;
	}
	@Column(name = "holder_mygoal")
	public String getHolderMygoal() {
		return holderMygoal;
	}
	public void setHolderMygoal(String holderMygoal) {
		this.holderMygoal = holderMygoal;
	}
	@Column(name = "manage_id")
	public Integer getManageId() {
		return manageId;
	}
	public void setManageId(Integer manageId) {
		this.manageId = manageId;
	}
	@Column(name = "holder_mygoal_date")
	public String getHolderMygoalDate() {
		return holderMygoalDate;
	}
	public void setHolderMygoalDate(String holderMygoalDate) {
		this.holderMygoalDate = holderMygoalDate;
	}
	public ShareHolder() {
		super();
	}
	public ShareHolder(Integer holderId, String holderLoginname, String holderName, String holderStatusId,
			String holderPhonenumber, String holderRecommendCode, Integer holderState, String holderEstablishDate,
			Integer holderRepresentative, String holderUsername, String holderPassword, String holderPosition,
			String holderBonus, String holderMygoal, Integer manageId, String holderMygoalDate) {
		super();
		this.holderId = holderId;
		this.holderLoginname = holderLoginname;
		this.holderName = holderName;
		this.holderStatusId = holderStatusId;
		this.holderPhonenumber = holderPhonenumber;
		this.holderRecommendCode = holderRecommendCode;
		this.holderState = holderState;
		this.holderEstablishDate = holderEstablishDate;
		this.holderRepresentative = holderRepresentative;
		this.holderUsername = holderUsername;
		this.holderPassword = holderPassword;
		this.holderPosition = holderPosition;
		this.holderBonus = holderBonus;
		this.holderMygoal = holderMygoal;
		this.manageId = manageId;
		this.holderMygoalDate = holderMygoalDate;
	}
	public ShareHolder(Map map) {
		this.holderId = (Integer) map.get("holder_id");
		this.holderLoginname = (String) map.get("holder_login_name");
		this.holderName = (String)map.get("holder_name");
		this.holderStatusId = (String)map.get("holder_status_id");
		this.holderPhonenumber = (String)map.get("holder_phone_number");
		this.holderRecommendCode =(String) map.get("holder_recommend_code");
		this.holderState = (Integer)map.get("holder_state");
		this.holderEstablishDate = (String)map.get("holder_establish_date");
		this.holderRepresentative = (Integer)map.get("holder_representative");
		this.holderUsername = (String)map.get("holder_username");
		this.holderPassword =(String) map.get("holder_password");
		this.holderPosition = (String)map.get("holder_position");
		this.holderBonus =(String) map.get("holder_bonus");
		this.holderMygoal = (String)map.get("holder_mygoal");
		this.manageId = (Integer)map.get("manage_id");
		this.holderMygoalDate =(String) map.get("holder_mygoal_date");
	}
	public ShareHolder update(ShareHolder shareHolder,ShareHolder pojo){
		if(StringUtil.isNotEmpty(shareHolder.getHolderLoginname())){
			pojo.setHolderLoginname(shareHolder.getHolderLoginname());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderName())){
			pojo.setHolderName(shareHolder.getHolderName());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderStatusId())){
			pojo.setHolderStatusId(shareHolder.getHolderStatusId());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderPhonenumber())){
			pojo.setHolderPhonenumber(shareHolder.getHolderPhonenumber());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderRecommendCode())){
			pojo.setHolderRecommendCode(shareHolder.getHolderRecommendCode());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderState())){
			pojo.setHolderState(shareHolder.getHolderState());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderEstablishDate())){
			pojo.setHolderEstablishDate(shareHolder.getHolderEstablishDate());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderRepresentative())){
			pojo.setHolderRepresentative(shareHolder.getHolderRepresentative());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderUsername())){
			pojo.setHolderUsername(shareHolder.getHolderUsername());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderPassword())){
			pojo.setHolderPassword(shareHolder.getHolderPassword());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderPosition())){
			pojo.setHolderPosition(shareHolder.getHolderPosition());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderBonus())){
			pojo.setHolderBonus(shareHolder.getHolderBonus());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderMygoal())){
			pojo.setHolderMygoal(shareHolder.getHolderMygoal());
		}
		if(StringUtil.isNotEmpty(shareHolder.getManageId())){
			pojo.setManageId(shareHolder.getManageId());
		}
		if(StringUtil.isNotEmpty(shareHolder.getHolderMygoalDate())){
			pojo.setHolderMygoalDate(shareHolder.getHolderMygoalDate());
		}
		return pojo;
	}
}

本人在MiniDao里定义了ResultType,可是发现映射返回的时候发现有的字段数据为空,有的不为空,这是为什么?

解决方案

40

你map取的时候的字段名称跟查询出来的能否对应!
有时候会原因是大小写而没有取到

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求指导:MiniDao查询数据库返回映射
喜欢 (0)
[1034331897@qq.com]
分享 (0)