Skip to content

Instantly share code, notes, and snippets.

@vjrngn
Last active April 24, 2019 13:27
Show Gist options
  • Save vjrngn/a521ca751570a3902f8a56276e03643b to your computer and use it in GitHub Desktop.
Save vjrngn/a521ca751570a3902f8a56276e03643b to your computer and use it in GitHub Desktop.
Order entity with @OneToMany relationship
package com.example.demo;
import javax.persistence.*;
import java.util.List;
@Entity
@Table(name = "orders")
public class Order {
@Id
int id;
@ManyToOne
@JoinColumn(name = "customer_id")
Customer customer;
@OneToMany(mappedBy = "order")
List<OrderLineItem> lineItems;
public Order() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment