apuntes:spring_web
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
apuntes:spring_web [2021/11/21 23:41] – [Relaciones entre clases] Santiago Faci | apuntes:spring_web [2021/11/21 23:43] (current) – [Relaciones entre clases] Santiago Faci | ||
---|---|---|---|
Line 314: | Line 314: | ||
@JoinColumn(name = " | @JoinColumn(name = " | ||
private User user; | private User user; | ||
+ | @ManyToOne | ||
+ | @JoinColumn(name = " | ||
+ | private Category category; | ||
} | } | ||
</ | </ | ||
Line 337: | Line 340: | ||
@OneToMany(mappedBy = " | @OneToMany(mappedBy = " | ||
+ | private List< | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code java> | ||
+ | @Data | ||
+ | @AllArgsConstructor | ||
+ | @NoArgsConstructor | ||
+ | @Entity(name = " | ||
+ | public class Category { | ||
+ | |||
+ | @Id | ||
+ | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
+ | private long id; | ||
+ | @Column | ||
+ | private String name; | ||
+ | @Column | ||
+ | private String description; | ||
+ | @Column | ||
+ | private float discount; | ||
+ | |||
+ | @OneToMany(mappedBy = " | ||
private List< | private List< | ||
} | } |
apuntes/spring_web.1637538067.txt.gz · Last modified: 2021/11/21 23:41 by Santiago Faci