JPA mapping: 3개의 글
Table 관계도 Entity @Entity(name = "tbl_product") public class Product { @Id @GeneratedValue private int productId; private String name; private int price; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name = "tbl_product_category", joinColumns = @JoinColumn(name = "product_id"), inverseJoinColumns = @JoinColumn(name = "category_id")) private List categories; public Prod..
Table 관계도 Entity @Entity(name = "tbl_user") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer userId; private String username; private String nickName; private String address; @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List orders; // getter and setter public boolean addOrder(Order order) { if(orders == null) orders = new ArrayList(); r..
Table 관계도 Entity @Entity public class Person { @Id @GeneratedValue private int id; private String name; @OneToOne @JoinColumn(name = "cellular_id") private Cellular cellular; public Person() {} public Person(String name, Cellular cellular) { this.name = name; this.cellular = cellular; } // getter and setter @Override public String toString() { return "Person{" + "id=" + id + ", name='" + name + ..