Bonsoir,
je veux créer 5 entity bean, donc 5 classes java, ces classes ont des correspondances, c'est-à-dire qu'il y des relations 0,n par exemple, et dans l'une des classes j'ai des collections java plus exactement j'ai des java.util.Set <modification> modification, et je veux faire des @OneToMany et des @ManyToOne mais j'ai une erreur lors du déploiement du jar sous JBoss.
Voici mes 2 classes :
Document.java
modification.java
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 package ejb; import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; import org.jboss.ejb3.naming.client.java.javaURLContextFactory; /* cette classe représente un document */ @Entity public class Document implements Serializable{ // les variables correspondent aux colonnes de la table Document de la base de données @Column(name = "nom", nullable = false) private String nom; // le nom du document @Column(name = "date_creation", nullable = false) private java.util.Date date_creation; // la date de création du document @Column(name = "emplacement", nullable = false) private String emplacement; // l'emplacement du document @Column(name = "modification", nullable = false) @OneToMany (mappedBy = "document") private java.util.Set<Modification> Modification; // la date de dernière modification //@Column(name = "tag", nullable = false) //private java.util.Set<Tag> tag; // la liste des tags représentant ce document private static final long serialVersionUID = -728268157L; @Column(name = "id", nullable = false) private Long id; // l'identifiant obligatoire pour la table @Column(name = "typeDocument", nullable = false) private TypeDocument typeDocument; // le type du document : ex technique, commercial .. // le constructeur qui est vide public Document() { super(); } // redéfinition de la méthode ToString public String toString() { return "Document" + " nom=" + nom + " date_creation=" + date_creation + " emplacement=" + emplacement + " id=" + id; } // les getters et setters public String getNom() { return this.nom; } public void setNom(String nom) { this.nom = nom; } public java.util.Date getDate_creation() { return this.date_creation; } public void setDate_creation(java.util.Date date_creation) { this.date_creation = date_creation; } public String getEmplacement() { return this.emplacement; } public void setEmplacement(String emplacement) { this.emplacement = emplacement; } //@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="document", targetEntity=Modification.class) public Collection<Modification> getModification() { if (Modification == null) { Modification = new java.util.HashSet<Modification>(); } return Modification; } public void setModification(java.util.Set<Modification> Modification) { this.Modification = Modification; } public void addModification(Modification Modification) { getModification().add(Modification); } public void removeModification(Modification Modification) { getModification().remove(Modification); } //@ManyToMany(cascade=CascadeType.ALL, mappedBy="tags", targetEntity=Tag.class) //@JoinTable(name="document_tag") /*public java.util.Set<Tag> getTag() { if (tag == null) { tag = new java.util.HashSet<Tag>(); } return tag; } public void setTag(java.util.Set<Tag> tag) { this.tag = tag; } public void addTag(Tag tag) { getTag().add(tag); } public void removeTag(Tag tag) { getTag().remove(tag); } */ @Id // tag définissant la clé primaire @GeneratedValue(strategy=GenerationType.AUTO) // tag indiquant que la clé est auto générée public Long getId() { return this.id; } public void setId(Long id) { this.id = id; } //@OneToOne(mappedBy="typeID") public TypeDocument getTypeDocument() { return this.typeDocument; } public void setTypeDocument(TypeDocument typeDocument) { this.typeDocument = typeDocument; } }
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 package ejb; import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; /* cette classe représente une modification d'un document */ @Entity public class Modification implements Serializable { // les variables correspondent aux colonnes de la table Modification de la base de données private java.util.Date date; // la date de modification private String commentaire; // le commentaire pour expliqué ce qu'il a été fait comme modification @ManyToOne @JoinColumn(name="document", nullable = false) private Document document; // représente le document qui a été modifié private User user; // représente le user qui a fait cette modification private static final long serialVersionUID = 258313988L; private Long id; // identifiant obligatoire pour la table // redéfinition de la méthode toString public String toString() { return "Modification" + " date=" + date + " commentaire=" + commentaire + " id=" + id; } // le constructeur vide public Modification() { super(); } // les getters et les setters public java.util.Date getDate() { return this.date; } public void setDate(java.util.Date date) { this.date = date; } public String getCommentaire() { return this.commentaire; } public void setCommentaire(String commentaire) { this.commentaire = commentaire; } //@ManyToOne(optional=false) public Document getDocument() { return this.document; } public void setDocument(Document document) { this.document = document; } //@OneToOne(mappedBy="userID") public User getUser() { return this.user; } public void setUser(User user) { this.user = user; } @Id // tag définissant la clé primaire @GeneratedValue(strategy=GenerationType.AUTO) // tag indiquant que la clé est auto générée public Long getId() { return this.id; } public void setId(Long id) { this.id = id; } }
ensuite voici mon fichier persistence.xml :
et enfin lorsque j'exporte mon projet en jar sous jboss voici l'erreur qui s'affiche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0"> <persistence-unit name="idocUnit"> <jta-data-source>java:PostgresDS</jta-data-source> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.hbm2ddl.auto" value="update" /> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /> <property name="connection.driver_class" value="org.postgresql.Driver" /> <property name="transaction.factory_class" value="org.hibernate.transaction.JDBCTransactionFactory" /> <property name="current_session_context_class" value="thread" /> </properties> </persistenc
si quelqu'un peut m'aider, je suis preneur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 17:11:14,840 WARN [EJB3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null et l'autre erreur : org.hibernate.mapping : could not determine type for : java.util.Collection, for columns : [org.hibernate.mapping.Column(modification)]
Merci
Partager