SpringDataJpa学习(二) 主键生成策略

关于属性注解的知识

package cn.ysk.domain;

import javax.persistence.*;

/**
 * 客户实体类
 *      配置映射关系
 *          1.实体类和表的映射关系
 *              @Entity 声明实体类
 *              @Table  配置实体类和表的映射关系
 *                  name:配置数据库表的名称
 *           2.实体类中属性和表中字段的映射关系
 *              @Id 声明主键的配置
 *              @GeneratedValue 配置主键的生成策略
 *                  strategy:
 *                      GenerationType.IDENTITY : 自增  mysql数据库支持
 *                          *底层数据库必须支持自动增长(底层数据库支持的自动增长方式,对id自增)
 *                      GenerationType.SEQUENCE : 序列  oracle数据库支持
 *                          *底层数据库必须支持序列
 *                      GenerationType.TABLE : jpa提供的一种机制,通过一张数据库表的形式帮助我们完成主键的自增
 *                      GenerationType.AUTO : 程序自动的帮助我们选择主键生成策略
 *
 *              @Column 配置属性和字段的映射关系
 *                  name 数据库表中字段的名称
 *
 *
 * @Author ysk
 * @Date 2020/3/5 21:21
 * @Version 1.0
 */

@Entity
@Table(name = "cst_customer")
public class Customer {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "cust_id")
    private Long custId;
    @Column(name = "cust_name")
    private String custName;
    @Column(name = "cust_source")
    private String custSource;
    @Column(name = "cust_level")
    private String custLevel;
    @Column(name = "cust_industry")
    private String custIndustry;
    @Column(name = "cust_phone")
    private String custPhone;
    @Column(name = "cust_address")
    private String custAddress;

    public Customer() {
    }

    public Long getCustId() {
        return custId;
    }

    public void setCustId(Long custId) {
        this.custId = custId;
    }

    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    public String getCustSource() {
        return custSource;
    }

    public void setCustSource(String custSource) {
        this.custSource = custSource;
    }

    public String getCustLevel() {
        return custLevel;
    }

    public void setCustLevel(String custLevel) {
        this.custLevel = custLevel;
    }

    public String getCustIndustry() {
        return custIndustry;
    }

    public void setCustIndustry(String custIndustry) {
        this.custIndustry = custIndustry;
    }

    public String getCustPhone() {
        return custPhone;
    }

    public void setCustPhone(String custPhone) {
        this.custPhone = custPhone;
    }

    public String getCustAddress() {
        return custAddress;
    }

    public void setCustAddress(String custAddress) {
        this.custAddress = custAddress;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "custId=" + custId +
                ", custName='" + custName + '\'' +
                ", custSource='" + custSource + '\'' +
                ", custLevel='" + custLevel + '\'' +
                ", custIndustry='" + custIndustry + '\'' +
                ", custPhone='" + custPhone + '\'' +
                ", custAddress='" + custAddress + '\'' +
                '}';
    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值