· 7 years ago · Dec 21, 2018, 10:20 AM
1@Id
2 @Column(name = "id")
3 @GeneratedValue(strategy = GenerationType.IDENTITY)
4 private Long id;
5
6 @Column(name = "langue")
7 private String langue;
8
9 @Column(name = "traduction")
10 private String traduction;
11
12 @JsonBackReference(value = "mot-traduction")
13 @ManyToOne(fetch = FetchType.EAGER)
14 @JoinColumn(name = "idMot", nullable = false, insertable = true, updatable = false)
15 private Mot mot;
16
17 @CreationTimestamp
18 @Column(name = "dateCreation")
19 private Date dateCreation;
20
21
22**Here is the mot model:**
23@Id
24 @Column(name = "id")
25 @GeneratedValue(strategy = GenerationType.AUTO)
26 private Long id;
27
28 @Column(name = "libelle")
29 private String libelle;
30
31 @JsonBackReference(value = "user-mot")
32 @ManyToOne(fetch = FetchType.EAGER)
33 @JoinColumn(name = "idUser", nullable = false, insertable = true, updatable = false)
34 private User user;
35
36 /** les traductions. */
37 @JsonManagedReference(value = "mot-traduction")
38 @OneToMany(mappedBy = "mot", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
39 private Set<Traduction> traductions;
40
41 @CreationTimestamp
42 @Column(name = "dateCreation")
43 private Date dateCreation;
44
45DROP TABLE IF EXISTS `traduction`;
46/*!40101 SET @saved_cs_client = @@character_set_client */;
47/*!40101 SET character_set_client = utf8 */;
48CREATE TABLE `traduction` (
49 `id` bigint(20) NOT NULL AUTO_INCREMENT,
50 `langue` varchar(100) DEFAULT NULL,
51 `traduction` varchar(100) DEFAULT NULL,
52 `idMot` bigint(20) DEFAULT NULL,
53 `dateCreation` datetime DEFAULT NULL,
54 PRIMARY KEY (`id`),
55 KEY `idMot_idx` (`idMot`),
56 CONSTRAINT `idMot` FOREIGN KEY (`idMot`) REFERENCES `mot` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
57) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
58/*!40101 SET character_set_client = @saved_cs_client */;