Bonjour,
Je suis actuellement confronté a un problème, et je n'arrive pas a le résoudre.
J'ai une base hibernate avec a l'interieur une table etudiant
J'obtiens donc un fichier Etudiant.hbm.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 REATE DATABASE Hibernate; USE Hibernate; CREATE TABLE Etudiant ( Pseudo CHAR(10) NOT NULL, Nom CHAR(25) NOT NULL, Prenom CHAR(25) NOT NULL , Age int(2) NOT NULL, PRIMARY KEY (Pseudo) );Mais lorsque je fais un
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 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="Modele"> <class name="Etudiant" table="etudiant" > <meta attribute="sync-DAO">false</meta> <id name="Id" type="string" column="Pseudo" > <generator class="native"/> </id> <property name="Pseudo" column="Pseudo" type="string" not-null="true" length="10" /> <property name="Nom" column="Nom" type="string" not-null="true" length="25" /> <property name="Prenom" column="Prenom" type="string" not-null="true" length="25" /> <property name="Age" column="Age" type="integer" not-null="true" length="10" /> </class> </hibernate-mapping>J'obtiens l'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Etudiant eleve = new Etudiant(); eleve.setNom("TestNom"); eleve.setPseudo("pseudo1"); eleve.setPrenom("TestPrenom"); eleve.setAge(new Integer(12)); session.save(eleve);Ça fait plusieurs jours que je tourne en rond, quelqu'un peut il m'aider?!
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 juin 05, 2013 2:20:40 PM org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.3.1.GA juin 05, 2013 2:20:40 PM org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found juin 05, 2013 2:20:40 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : javassist juin 05, 2013 2:20:40 PM org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling juin 05, 2013 2:20:40 PM org.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml juin 05, 2013 2:20:40 PM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml juin 05, 2013 2:20:40 PM org.hibernate.cfg.Configuration addResource INFO: Reading mappings from resource : Etudiant.hbm.xml juin 05, 2013 2:20:41 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: Modele.Etudiant -> etudiant juin 05, 2013 2:20:41 PM org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null Initial SessionFactory creation failed.org.hibernate.MappingException: Repeated column in mapping for entity: Modele.Etudiant column: Pseudo (should be mapped with insert="false" update="false") Exception in thread "main" java.lang.ExceptionInInitializerError at Modele.dao.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:19) at Modele.dao.EtudiantDAO.main(EtudiantDAO.java:22) Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: Modele.Etudiant column: Pseudo (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:670) at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:692) at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:714) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:468) at org.hibernate.mapping.RootClass.validate(RootClass.java:215) at org.hibernate.cfg.Configuration.validate(Configuration.java:1135) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320) at Modele.dao.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:14) ... 1 more
J'arrive a lire dans la base, mais pas a écrire dedans...
Merci
Partager