Strong answer
A JPA entity is a persistent identity managed by a persistence context, not just a row-shaped DTO. Map relationships from the side that owns the foreign key, default to lazy associations, keep bidirectional links consistent through helper methods, and give the entity a stable notion of identity. Relationship choices decide which SQL runs later, so model them from real access patterns rather than mirroring every table join.
Java example
1@Entity
2@Table(name = "orders")
3class Order {
4 @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
5 private Long id;
6
7 @ManyToOne(fetch = FetchType.LAZY, optional = false)
8 @JoinColumn(name = "customer_id")
9 private Customer customer;
10
11 @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
12 private List<OrderLine> lines = new ArrayList<>();
13
14 void addLine(OrderLine line) {
15 lines.add(line);
16 line.setOrder(this); // keep both sides consistent
17 }
18}