JPA 或者Hibernate 实体类说明
这里简单介绍Hibernate的Annotation注解
一、声明实体
@Entity
对实体注释。任何Hibernate映射对象都要有这个注释
@Table
声明此对象映射到数据库的数据表,通过它可以为实体指定表(talbe),目录(Catalog)和schema的名字。该注释不是必须的,如果没有则系统使用默认值(实体的短类名)。
@Version
该注释可用于在实体Bean中添加乐观锁支持。
二、声明主键
@Id
声明此属性为主键。该属性值可以通过应该自身创建,但是Hibernate推荐通过Hibernate生成
@GeneratedValue
指定主键的生成策略。有如下四个值
TABLE:使用表保存id值
IDENTITY:identitycolumn
SEQUENCR :sequence
AUTO:根据数据库的不同使用上面三个
三、声明普通属性
@Column
可以放在属性或者get方法上面
@Column(name=" contact_name ")
private String contactName;
或者
@Column(name=" contact_name ")
public String getName() {
return name;
}
注:当POJO有属性不需要映射的时候一定要用@Transitent修饰,该注释表示此属性与表没有映射关系,只是一个暂时的属性。
如下 dingDiffId 跟数据库没关系,不需要存,那么就在属性上面加@Transitent
@Entity
@Table(name="order_info")
public class OrderInfoDO extends BaseUpdateDO {
/** 订单编号 */
@Id
private String id = null; /** 父单号 *//*
@Column(name="parent_order_num")
private String parentOrderNum = null;*/ /** 产品等级 */
@Column(name="product_grade")
private Integer productGrade = null; /** 产品名称 */
@Column(name="product_name")
private String productName = null; /** 优惠卷编号 */
@Column(name="coupon_id")
private String couponId = null; /** 收获地址信息 *//*
@OneToOne(cascade={CascadeType.REFRESH})
@JoinColumn(name="order_address_id")
private OrderAddressDO address = null;*/ /** 钉钉编号 */
@Column(name="ding_id")
private String dingId = null; /** 钉钉应用编号 *//*
@Column(name="app_id")
private String appId = null;*/ /** 用户编号 */
@Column(name="user_id")
private String userId = null; /** 用户名称 */
@Column(name="user_name")
private String userName = null; /** 公司 */
private String company = null; /** 邮箱 */
private String email = null; /** 服务用户编号 *//*
@Column(name="service_user_id")
private String serviceUserId = null; *//** 服务用户名称 *//*
@Column(name="service_user_name")
private String serviceUserName = null; *//** 订单类别 *//*
@Column(name="oder_type")
private String oderType = null;*/ /** 产品类型组 */
@Column(name="product_group", nullable=false)
private String productGroup = null; /** 产品类型 */
@Column(name="product_type")
private int productType = 0; /** 产品类型值 */
@Column(name="product_type_value")
private String productTypeValue = null; /** 支付方式 *//*
@Column(name="pay_type")
private Integer payType = null;*/ /** 支付账户名称 */
@Column(name="pay_name")
private String payName = null; /** 设计价格 单位:分 */
@Column(name="designer_money")
private int designerMoney = 0; /** 制作价格 单位:分 *//*
@Column(name="make_money")
private Integer makeMoney = null;*/ /** 用户下订单时补的差价金额 单位:分 */
@Column(name="difference_price")
private int differencePrice = 0; /** 支付金额 单位:分 */
@Column(name="pay_money")
private int payMoney = 0; /** 设计退款金额 单位:分 */
@Column(name="refund_designer_money")
private Integer refundDesignerMoney = null; /** 制作退款金额 单位:分 *//*
@Column(name="refund_make_money")
private Integer refundMakeMoney = null;*/ /** 总共退款金额 单位:分 */
@Column(name="refund_total_money")
private Integer refundTotalMoney = null; /** 退款账户 */
@Column(name="refund_account")
private String refundAccount = null; /** 退款备注信息 */
@Column(name="refund_remark")
private String refundRemark = null; /** 单价 单位:分 */
@Column(name="unit_price")
private int unitPrice = 0; /** 产品数量 */
@Column(name="product_num")
private int productNum = 0; /** 是否制作 *//*
@Column(name="is_make")
private boolean isMake = false; *//** 制作尺寸 *//*
@Column(name="make_size")
private String makeSize = null; *//** 制作数量 *//*
@Column(name="make_num")
private String makeNum = null;*/ /** 源文件 */
@Column(name="source_file")
private String sourceFile = null; /** 备注 */
@Column(name="remarks")
private String remarks = null; /** 评价信息 */
@Column(name="evaluate_msg")
private String evaluateMsg = null; /** 评价服务态度 */
@Column(name="evaluate_service")
private int evaluateService = 0; /** 评价设计水平 */
@Column(name="evaluate_design")
private int evaluateDesign = 0; /** 服务流程编号 */
@Column(name="flow_id")
private String flowId = null; /** 订单状态 */
private int status = 0; /** 处理状态 */
@Column(name="handle_status")
private int handleStatus = 0; /** 退款状态 */
@Column(name="refund_status")
private Integer refundStatus = null; /** 支付时间 */
@Column(name="pay_time")
private Timestamp payTime = null; /** 联系方式 */
private String tel = null; /** 延期说明 */
@Column(name="delay_remark")
private String delayRemark = null; /** 用户定稿稿件编号 */
@Column(name="final_id")
private String finalId = null; /** 初稿用户不满意标识符 true:不满意 */
@Column(name="first_unsatisfy")
private Boolean firstUnsatisfy = null; /** 初稿稿件集合 */
@Transient
private List<OrderRecordDO> firsts = null; /** CRM推送状态 false:未推送 */
/*@Column(name="crm_flag")
private boolean crmFlag = false;*/ /** 钉钉订单编号*/
@Column(name="ding_order_id")
private String dingOrderId = null; /** 创建日期到天格式*/
@Column(name="est_date")
private Integer estDate = null; /** order_difference 表用的ding_diff_id*/
@Transient
private String dingDiffId = null; public String getId() {
return id;
} public void setId(String id) {
this.id = id;
} /*public String getParentOrderNum() {
return parentOrderNum;
} public void setParentOrderNum(String parentOrderNum) {
this.parentOrderNum = parentOrderNum;
}*/ public Integer getProductGrade() {
return productGrade;
} public void setProductGrade(Integer productGrade) {
this.productGrade = productGrade;
} public String getProductName() {
return productName;
} public void setProductName(String productName) {
this.productName = productName;
} public String getCouponId() {
return couponId;
} public void setCouponId(String couponId) {
this.couponId = couponId;
} /*public OrderAddressDO getAddress() {
return address;
} public void setAddress(OrderAddressDO address) {
this.address = address;
}*/ public String getDingId() {
return dingId;
} public void setDingId(String dingId) {
this.dingId = dingId;
} /*public String getAppId() {
return appId;
} public void setAppId(String appId) {
this.appId = appId;
}*/ public String getUserId() {
return userId;
} public void setUserId(String userId) {
this.userId = userId;
} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getCompany() {
return company;
} public void setCompany(String company) {
this.company = company;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} /*public String getServiceUserId() {
return serviceUserId;
} public void setServiceUserId(String serviceUserId) {
this.serviceUserId = serviceUserId;
} public String getServiceUserName() {
return serviceUserName;
} public void setServiceUserName(String serviceUserName) {
this.serviceUserName = serviceUserName;
} public String getOderType() {
return oderType;
} public void setOderType(String oderType) {
this.oderType = oderType;
}*/ public String getProductGroup() {
return productGroup;
} public void setProductGroup(String productGroup) {
this.productGroup = productGroup;
} public int getProductType() {
return productType;
} public void setProductType(int productType) {
this.productType = productType;
} public String getProductTypeValue() {
return productTypeValue;
} public void setProductTypeValue(String productTypeValue) {
this.productTypeValue = productTypeValue;
} /*public Integer getPayType() {
return payType;
} public void setPayType(Integer payType) {
this.payType = payType;
}*/ public String getPayName() {
return payName;
} public void setPayName(String payName) {
this.payName = payName;
} public int getDesignerMoney() {
return designerMoney;
} public void setDesignerMoney(int designerMoney) {
this.designerMoney = designerMoney;
} /*public Integer getMakeMoney() {
return makeMoney;
} public void setMakeMoney(Integer makeMoney) {
this.makeMoney = makeMoney;
}*/ public int getDifferencePrice() {
return differencePrice;
} public void setDifferencePrice(int differencePrice) {
this.differencePrice = differencePrice;
} public int getPayMoney() {
return payMoney;
} public void setPayMoney(int payMoney) {
this.payMoney = payMoney;
} public Integer getRefundDesignerMoney() {
return refundDesignerMoney;
} public void setRefundDesignerMoney(Integer refundDesignerMoney) {
this.refundDesignerMoney = refundDesignerMoney;
} /*public Integer getRefundMakeMoney() {
return refundMakeMoney;
} public void setRefundMakeMoney(Integer refundMakeMoney) {
this.refundMakeMoney = refundMakeMoney;
}*/ public Integer getRefundTotalMoney() {
return refundTotalMoney;
} public void setRefundTotalMoney(Integer refundTotalMoney) {
this.refundTotalMoney = refundTotalMoney;
} public String getRefundAccount() {
return refundAccount;
} public void setRefundAccount(String refundAccount) {
this.refundAccount = refundAccount;
} public String getRefundRemark() {
return refundRemark;
} public void setRefundRemark(String refundRemark) {
this.refundRemark = refundRemark;
} public int getUnitPrice() {
return unitPrice;
} public void setUnitPrice(int unitPrice) {
this.unitPrice = unitPrice;
} public int getProductNum() {
return productNum;
} public void setProductNum(int productNum) {
this.productNum = productNum;
} /*public boolean isMake() {
return isMake;
} public void setMake(boolean make) {
isMake = make;
} public String getMakeSize() {
return makeSize;
} public void setMakeSize(String makeSize) {
this.makeSize = makeSize;
} public String getMakeNum() {
return makeNum;
} public void setMakeNum(String makeNum) {
this.makeNum = makeNum;
}*/ public String getSourceFile() {
return sourceFile;
} public void setSourceFile(String sourceFile) {
this.sourceFile = sourceFile;
} public String getRemarks() {
return remarks;
} public void setRemarks(String remarks) {
this.remarks = remarks;
} public String getEvaluateMsg() {
return evaluateMsg;
} public void setEvaluateMsg(String evaluateMsg) {
this.evaluateMsg = evaluateMsg;
} public int getEvaluateService() {
return evaluateService;
} public void setEvaluateService(int evaluateService) {
this.evaluateService = evaluateService;
} public int getEvaluateDesign() {
return evaluateDesign;
} public void setEvaluateDesign(int evaluateDesign) {
this.evaluateDesign = evaluateDesign;
} public String getFlowId() {
return flowId;
} public void setFlowId(String flowId) {
this.flowId = flowId;
} public int getStatus() {
return status;
} public void setStatus(int status) {
this.status = status;
} public int getHandleStatus() {
return handleStatus;
} public void setHandleStatus(int handleStatus) {
this.handleStatus = handleStatus;
} public Integer getRefundStatus() {
return refundStatus;
} public void setRefundStatus(Integer refundStatus) {
this.refundStatus = refundStatus;
} public Timestamp getPayTime() {
return payTime;
} public void setPayTime(Timestamp payTime) {
this.payTime = payTime;
} public String getTel() {
return tel;
} public void setTel(String tel) {
this.tel = tel;
} public String getDelayRemark() {
return delayRemark;
} public void setDelayRemark(String delayRemark) {
this.delayRemark = delayRemark;
} public String getFinalId() {
return finalId;
} public void setFinalId(String finalId) {
this.finalId = finalId;
} public Boolean isFirstUnsatisfy() {
return firstUnsatisfy;
} public void setFirstUnsatisfy(Boolean firstUnsatisfy) {
this.firstUnsatisfy = firstUnsatisfy;
} public List<OrderRecordDO> getFirsts() {
return firsts;
} public void setFirsts(List<OrderRecordDO> firsts) {
this.firsts = firsts;
} /*public boolean isCrmFlag() {
return crmFlag;
} public void setCrmFlag(boolean crmFlag) {
this.crmFlag = crmFlag;
}*/ public String getDingOrderId() {
return dingOrderId;
} public void setDingOrderId(String dingOrderId) {
this.dingOrderId = dingOrderId;
} public Integer getEstDate() {
return estDate;
} public void setEstDate(Integer estDate) {
this.estDate = estDate;
} public String getDingDiffId() {
return dingDiffId;
} public void setDingDiffId(String dingDiffId) {
this.dingDiffId = dingDiffId;
} @Override
public String toString() {
return "OrderInfoDO{" +
"id='" + id + '\'' +
", productGrade=" + productGrade +
", productName='" + productName + '\'' +
", couponId='" + couponId + '\'' +
", dingId='" + dingId + '\'' +
", userId='" + userId + '\'' +
", userName='" + userName + '\'' +
", company='" + company + '\'' +
", email='" + email + '\'' +
", productGroup='" + productGroup + '\'' +
", productType=" + productType +
", productTypeValue='" + productTypeValue + '\'' +
", payName='" + payName + '\'' +
", designerMoney=" + designerMoney +
", differencePrice=" + differencePrice +
", payMoney=" + payMoney +
", refundDesignerMoney=" + refundDesignerMoney +
", refundTotalMoney=" + refundTotalMoney +
", refundAccount='" + refundAccount + '\'' +
", refundRemark='" + refundRemark + '\'' +
", unitPrice=" + unitPrice +
", productNum=" + productNum +
", sourceFile='" + sourceFile + '\'' +
", remarks='" + remarks + '\'' +
", evaluateMsg='" + evaluateMsg + '\'' +
", evaluateService=" + evaluateService +
", evaluateDesign=" + evaluateDesign +
", flowId='" + flowId + '\'' +
", status=" + status +
", handleStatus=" + handleStatus +
", refundStatus=" + refundStatus +
", payTime=" + payTime +
", tel='" + tel + '\'' +
", delayRemark='" + delayRemark + '\'' +
", finalId='" + finalId + '\'' +
", firstUnsatisfy=" + firstUnsatisfy +
", firsts=" + firsts +
", dingOrderId=" + dingOrderId +
", estDate=" + estDate +
", dingDiffId=" + dingDiffId +
"} " + super.toString();
}
}
JPA 或者Hibernate 实体类说明的更多相关文章
- spring+hibernate实体类注解详解(非原创) + cascade属性取值
@Entity //继承策略.另一个类继承本类,那么本类里的属性应用到另一个类中 @Inheritance(strategy = InheritanceType.JOINED ) @Table(nam ...
- eclipse从数据库逆向生成Hibernate实体类
做项目必然要先进行数据库表设计,然后根据数据库设计建立实体类(VO),这是理所当然的,但是到公司里做项目后,让我认识到,没有说既进行完数据库设计后还要再“自己”建立一变VO.意思是,在项目设计时,要么 ...
- 06.Hibernate实体类生命周期
前言:Session接口是Hibernate向应用程序提供的操作数据库的主要接口,它提供了基本的增删查改方法,而且Session具有一个缓存它是Hibernate的一级缓存.站在持久化层的角度 ...
- [转]eclipse借助hibernate tool从数据库逆向生成Hibernate实体类
如何从数据库逆向生成Hibernate实体类呢??? 1. 首先,要在eclipse中采用自带的数据库管理器(Data Management),连通你的数据库: 然后选择数据库,这里用的oracle, ...
- Intellij idea生成Hibernate实体类
反向生成基于注解的Hibernate实体类 1. 为项目添加Hibernate支持 2. 在IDE右边找到database,然后按照步骤添加数据. 3. 保存后.在主面板左侧有persistence, ...
- Eclipse从数据库逆向生成Hibernate实体类和映射文件(Eclipse插件系列之HibernateTools)
♣下载安装Eclipse插件(HibernateTools) ♣Eclipse连接数据库(Mysql5.7) ♣新建hibernate.properties和hibernate.cfg.xml文件 ♣ ...
- (转) Eclipse通过HibernateTools实现逆向生成Hibernate实体类
背景:工作中使用Hibernate进行持久化的开发工作,所以有必要详细了解这方面的知识. ps:这里有个问题就是刷新表的时候速度太慢了.还不如自己手动去创建.如果表太多倒是可以采取批量生成的策略. 在 ...
- myeclipse通过数据表生成jpa或hibernate实体---https://blog.csdn.net/partner4java/article/details/8560289
myeclipse通过数据表生成jpa或hibernate实体-----https://blog.csdn.net/partner4java/article/details/8560289
- 使用jpa时,实体类有不存在数据库中的字段
使用jpa时,实体类有不存在数据库中的字段.在改属性上面加上这个注解@Transient就可以解决问题.
随机推荐
- Linux CentOS 7 防火墙与端口设置操作
CentOS升级到7之后用firewall代替了iptables来设置Linux端口, 下面是具体的设置方法: []:选填 <>:必填 [<zone>]:作用域(block.d ...
- IntelliJ IDEA和Eclipse快捷键对比总结
- XMLHttpRequest status为0
//创建XMLHttpRequest()对象 var request = new XMLHttpRequest(); ...... 今天写一个ajax , 明明是有结果返回的,但得到的request ...
- Solr——Java应用
Solr有一个客户端SolrJ 创建一个Java Project 引入Jar包 添加test类 package com.solr.test; import java.io.IOException; i ...
- Python模拟百度自动输入搜索功能
# 访问百度,模拟自动输入搜索 # 代码中引入selenium版本为:3.4.3 # 通过Chrom浏览器访问发起请求 # Chrom版本:59 ,chromdriver:2.3 # 需要对应版本的C ...
- 【Winform-自定义控件】DataGridView 单元格合并和二维表头
DataGridView单元格合并和二维表头应用: //DataGridView绑定数据 DataTable dt = new DataTable(); dt.Columns.Add("); ...
- html上标与下标应用
HTML 标签应用示例: <html> <head> <meta http-equiv="Content-Type" content="te ...
- 51 Nod 1072 威佐夫游戏
https://baike.baidu.com/item/%E5%A8%81%E4%BD%90%E5%A4%AB%E5%8D%9A%E5%BC%88/19858256?fr=aladdin&f ...
- Selenium 的页面加载以及几种等待的问题
1. PageLoadStrategy : 当调用driver.get("https://xxxx.xxx.xxx")来访问某页面时,get方法通常会阻塞浏览器直到页面完全加载后才 ...
- 记一次期待已久的渗透 从phpcms到thinkphp
0X01 前言 这是刚刚开始学习渗透的一个目标吧 这个站从刚开始学的那一天起,就想把他日下来. 可能是自己的信息收集能力太差了吧,导致一直无从下手 没有进展.这是需要慢慢积累的过程.还需努力学习. 0 ...