Last active
April 24, 2019 13:27
-
-
Save vjrngn/a521ca751570a3902f8a56276e03643b to your computer and use it in GitHub Desktop.
Order entity with @onetomany relationship
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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