package org.zheng.demo.entity;

import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapsId;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "T_ORDER_ITEM")
@Data
@NoArgsConstructor
public class OrderLineItem {

	@EmbeddedId
	private OrderItemId id;// primary key of the order line item

	@MapsId("orderId") // maps to the "orderId" field in "OrderItemId" class
	@ManyToOne
	@JoinColumn(name = "order_id") // foreign key column in T_Order_Item Table
	private Order order;

	@MapsId("productId") // maps to "productId" in "OrderItemId"
	@ManyToOne
	@JoinColumn(name = "product_id") // foreign key column in T_Order_Item Table
	private Product product;

	private Integer quantity;
}
