Bonjour, j'ai créé un JPA project, j'ai 2 classes : Poste et PostePK qui correspondent à une table poste qui n'a pas encore été créé.
Dans ma classe poste au niveau du @Entity j'ai 2 messages d'erreurs :
this class as a composite primary key, it must use and id class
et : Table "Poste" cannot be resovled (celui là je peux le comprendre car ma table n'est pas créée mais je veux créer ma table à partir des JPA).
Mon persistence.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 import java.io.Serializable; import java.lang.String; import javax.persistence.*; @Entity public class Poste implements Serializable { @Id private int id_poste; @Id private String nom_poste; private static final long serialVersionUID = 1L; public Poste() { super(); } public int getId_poste() { return this.id_poste; } public void setId_poste(int id_poste) { this.id_poste = id_poste; } public String getNom_poste() { return this.nom_poste; } public void setNom_poste(String nom_poste) { this.nom_poste = nom_poste; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="UserManagement"> <provider> oracle.toplink.essentials.PersistenceProvider </provider> <class>ServicesUM.Poste</class> <properties> <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" /> <property name="toplink.jdbc.url" value="jdbc:mysql://localhost/xxx"/> <property name="toplink.jdbc.user" value="root" /> <property name="toplink.jdbc.password" value="root" /> <property name="toplink.logging.level" value="INFO" /> </properties> </persistence-unit> </persistence>








Répondre avec citation



Partager