Bonjour ,

je veux sauvgader des données se trouvant dans un fichiers xml, et j'utilise pour cela hibernate3. alors j'ai ecrit le code suivant (il n'est pas complet..):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
......
Session xmlSession = session.getSession(EntityMode.DOM4J);
		Transaction tx=session.beginTransaction();
 
 
		for (Iterator it=contact.iterator(); it.hasNext(); ) {
			xmlSession.saveOrUpdate("dao.ContactDao",it.next());
                }	................
mais ceci m'affiche l'erreur suivante :
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
..............Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into contact (contactPrenom, contactnom, nomEpouse, profession, details, adresseContact, companyId, contactId) values (?, ?, ?, ?, ?, ?, ?, ?)
- SQL Error: 1048, SQLState: 23000
- Column 'contactNom' cannot be null
- Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:343)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
	at dao.Mapping.<init>(Mapping.java:59)
	at dao.Mapping.main(Mapping.java:81)
Caused by: java.sql.BatchUpdateException: Column 'contactNom' cannot be null
	at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:657)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
	... 9 more........
j'ai essayé de catcher l'erreur mais ça marche pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
for (Iterator it=contact.iterator(); it.hasNext(); ) {
			Object c=it.next();
			try{
				xmlSession.saveOrUpdate("dao.ContactDao",it.next());
				log.info("session succes.......");
			}
			catch(Exception e){
				log.info("erreur de sauvgarde.......");
				save.add(c);
			}
j'ai essayé avec catch(Throwable)et aussi avec RuntimeException toujours rien
..
est ce que quelqu'un peut m'aider ?

cordialement