Springboot休眠实体映射

问题描述:

我有三个表在每个表中的主键:表包名,表客户和表租金。Springboot休眠实体映射

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 
} 

我阙stion是: 如何从table customer中将tabel packetname和idcustomer的idpacketname,packetname获取到表租金中。所以我知道一个客户租一个数据包,并提供有关expdate和rentstatus的租金详情。

对不起,我写不好的问题,我在这个计算器是新 谢谢你们:)

如果我理解正确的话,表出租应该代表多到多个表PACKETNAME和客户之间的关系。因此,您应该在租赁实体中拥有PacketName和Customer类型的属性,并使用propper注释。

Short example: