Be ready to make your future bright with us.
@Entity@AllArgsConstructor@NoArgsConstructor@ToString@Datapublic class Customer { @Id @GeneratedValue private int id; private String customerName; private String customerContact; @OneToOne(mappedBy = "customer", cascade = CascadeType.ALL) private Order order; public Customer(String customerName, String customerContact){ this.customerContact = customerContact; this.customerName = customerName; }}
@Entity@AllArgsConstructor@NoArgsConstructor@ToString@Datapublic class Customer { @Id @GeneratedValue private int id; private String customerName; private String customerContact; @OneToOne(mappedBy = "customer", cascade = CascadeType.ALL) private Order order; public Customer(String customerName, String customerContact){ this.customerContact = customerContact; this.customerName = customerName; }
}
@Entity@Data@AllArgsConstructor@NoArgsConstructor@Table(name = "orders")public class Order { @Id @GeneratedValue private int id; private double total; private String orderType; private Date orderDate; @OneToOne @MapsId private Customer customer; public Order(double total, String orderType, Date orderDate) { this.total = total; this.orderType = orderType; this.orderDate = orderDate; }}
Comments
Post a Comment
Let me know your doubts