Bonsoir,

Etant débutant avec Hibernate, je rencontre un problème au niveau d'un fichier de mapping

voici le code JAVA des POJO :

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
public class Document {
 
	private Long id;
	protected String titre;
	protected String desription;
	protected String date;
	protected Set<Auteur> auteurs;
 
	public Document(){
		auteurs = new HashSet<Auteur>();
	}
 
	public Long getId(){
		return this.id;
	}
 
	public void setId(Long id){
		this.id = id;
	}
 
	public String getTitre(){
		return this.titre;
	}
 
	public void setTitre(String titre){
		this.titre = titre;
	}
 
	public String getDescription(){
		return this.desription;
	}
 
	public void setDescription(String description){
		this.desription = description;
	}
 
	public String getDate(){
		return this.date;
	}
 
	public void setDate(String date){
		this.date = date;
	}
 
	public Set<Auteur> getAuteur(){
		return auteurs;
	}
 
	public void setAuteur(Auteur auteur){
		this.auteurs.add(auteur);
	}
 
}
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
 
public class Auteur {
	private Long id;
 
	private String prenom;
	private String nom;
	private Set<Document>documents;
 
	public Auteur(){
		documents = new HashSet<Document>();
	}
 
	public Long getId(){
		return this.id;
	}
 
	public void setId(Long id){
		this.id = id;
	}
 
	public String getPrenom(){
		return this.prenom;
	}
 
	public void setPrenom(String prenom){
		this.prenom = prenom;
	}
 
	public String getNom(){
		return this.nom;
	}
 
	public void setNom(String nom){
		this.nom = nom;
	}
 
	public Set<Document> getDocuments(){
		return this.documents;
	}
 
	public void setDocuments(Document document){
		this.documents.add(document);
	}
 
}
Les fichiers mapping associés :
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
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate//Hibernate Mapping DTD 3.0//EN"
								   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping package="Bibliotheque">
	<class name="Document" table="DOCUMENT">
 
		<id name="id" column="DOCUMENT_ID">
			<generator class="increment"/>
		</id>
		<property name="titre"/>
		<property name="description"/>
		<property name="date"/>
 
		<set name="auteurs" table="AUTEUR_DOCUMENT" inverse="true">
			<key column="DOCUMENT_ID"></key>
			<many-to-many column="AUTEUR_ID" class="Auteur"/>
		</set>
 
	</class>
</hibernate-mapping>
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
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate//Hibernate Mapping DTD 3.0//EN"
								   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping package="Bibliotheque">
	<class name="Auteur" table="AUTEUR">
		<id name="id" column="AUTEUR_ID">
			<generator class="increment"/>
		</id>
		<property name="nom"/>
		<property name="prenom"/>
 
		<set name="documents" table="AUTEUR_DOCUMENT">
			<key column="AUTEUR_ID"/>
			<many-to-many column="DOCUMENT_ID" class="Document"/>	
		</set>	
	</class>
</hibernate-mapping>
et le fichier conf :
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
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate//Hibernate Configuration DTD 3.0//EN"
								   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
<hibernate-configuration>
 
	<session-factory>
		<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="connection.url">jdbc:mysql://localhost/Library</property>
		<property name="connection.username">root</property>
		<property name="connection.password">password</property>
		<property name="dialect">org.hibernate.dialect.MySQLDialect</property>		
		<property name="show_sql">true</property>
		<property name="format_sql">true</property>
		<property name="hbm2ddl.auto">create</property>
 
		<property name="connection.pool_size">1</property>
		<property name="current_session_context_class">thread</property>
 
		<!-- mapping files -->
		<mapping resource="Bibliotheque/Auteur.hbm.xml"/>
		<mapping resource="Bibliotheque/Document.hbm.xml"/>
		<mapping resource="Bibliotheque/CD.hbm.xml"/>
		<mapping resource="Bibliotheque/Livre.hbm.xml"/>
	</session-factory>
 
</hibernate-configuration>
Et voici ce que j'obtiens avec ant:
[java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[java] log4j:WARN Please initialize the log4j system properly.
[java] org.hibernate.MappingException: Repeated column in mapping for entity: Bibliotheque.Document column: DOCUMENT_ID (should be mapped with insert="false" update="false")
[java] at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:670)
[java] at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:692)
[java] at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:714)
[java] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:468)
[java] at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
[java] at org.hibernate.cfg.Configuration.validate(Configuration.java:1135)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320)
[java] at util.HibernateUtil.initSessionFactory(Unknown Source)
[java] at util.HibernateUtil.getSessionFactory(Unknown Source)
[java] at util.HibernateUtil.getSession(Unknown Source)
[java] at util.HibernateUtil.create(Unknown Source)
[java] at util.HibernateUtil.run(Unknown Source)
[java] at util.HibernateUtil.main(Unknown Source)

Bien sûr je n'ai pas tout mis mais l'erreur viendrait bien du fichier de mapping document.hbm.xml

Merci d'avance pour vos réponses