其他分享
首页 > 其他分享> > 18-创建客户实体类并配置映射关系

18-创建客户实体类并配置映射关系

作者:互联网

package com.study.pojo;
/*
1、实体类和表的映射关系
    @Eitity  //声明实体类
    @Table(name = "表的名称")   //声明实体类和表的映射关系
2、类中属性和表中字段的映射关系
    @Id     //配置主键
    @GeneratedValue     //指定主键的生成策略
    @Column     //属性和表中字段的映射关系
 */

import javax.persistence.*;

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

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="cust_id")
    private Long custId;

    @Column(name="cust_address")
    private String custAddress;

    @Column(name="cust_industry")
    private String custIndustry;

    @Column(name="cust_level")
    private String custLevel;

    @Column(name="cust_name")
    private String custName;

    @Column(name="cust_phone")
    private String custPhone;

    @Column(name="cust_source")
    private String custSource;

    public Customer() {
    }

    public Customer(Long custId, String custAddress, String custIndustry, String custLevel, String custName, String custPhone, String custSource) {
        this.custId = custId;
        this.custAddress = custAddress;
        this.custIndustry = custIndustry;
        this.custLevel = custLevel;
        this.custName = custName;
        this.custPhone = custPhone;
        this.custSource = custSource;
    }

    public Long getCustId() {
        return custId;
    }

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

    public String getCustAddress() {
        return custAddress;
    }

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

    public String getCustIndustry() {
        return custIndustry;
    }

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

    public String getCustLevel() {
        return custLevel;
    }

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

    public String getCustName() {
        return custName;
    }

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

    public String getCustPhone() {
        return custPhone;
    }

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

    public String getCustSource() {
        return custSource;
    }

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

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

标签:custPhone,实体类,String,映射,18,custName,custIndustry,custSource,public
来源: https://www.cnblogs.com/morehair/p/15505699.html