Springboot Hibernate实体映射

时间:2017-05-08 06:12:28

标签: java mysql hibernate

我在每个表中有三个带主键的表:table packetname,table customer和table rent。

PacketName

public class PacketName implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer idpacket;
    private String packetname;
    private String packetdesc;
    private String packetprize;
    private String packettime;
    //getter and setter etc
}

客户

public class Customer implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long costumerid;

    private String costumername;
    private String governmentname;
    private String costumeraddress;
    private String costumeremail;
    @NotNull
    private String costumerphone;

    @NotNull
    private String customer_username;
    @NotNull
    private String customer_password;
    ...
    //getter and setter
}

租借

@Entity
public class Rent implements Serializable{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long idrent;

    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false)
    private Date registerdate;
    private Date updatedate;
    private Date expdate;
    private String rentstatus;
    ....
    //getter and setter
}

我的问题是: 如何从表客户的tabel packetname和idcustomer获取idpacketname,packetname到表租。所以我知道一个客户租用一个数据包,并提供关于expdate和rentstatus的表租金详情。

对不起我的写错题,我是这个stackoverflow的新手 谢谢你们:)

0 个答案:

没有答案