Bonjour,

Je viens de me lancer dans la réalisation d'un petite application web avec Hiberate pour la persistance de la couche de données. Et je rencontre quelques problèmes.

Pour commencer je développe sous Eclipse 3.2 + + Hibernate 3.1 + plugin eclispe hibernate synchronizeur.

J'ai une Table toute simple de type :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
 
CREATE TABLE utilisateurs
(
  iduser int8 NOT NULL,
  nom varchar(40) NOT NULL,
  prenom varchar(40) NOT NULL,
  "password" varchar(20) NOT NULL,
  datecm timestamp,
  issupprimable int4,
  CONSTRAINT cons_iduser PRIMARY KEY (iduser),
  CONSTRAINT utilisateurs_issupprimable_check CHECK (issupprimable = 0 OR issupprimable = 1)
)
1 - j'ai créé mon fichier de conf xml
2 - mon fichier de mapping
3 - Je synchronise (création auto des différentes classes de mapping)
4 - Création d'un classe de test.

Lorsque j'execute ma classe après compilation j'ai le message d'erreur suivant :


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
 
 
17 juil. 2006 21:33:07 org.hibernate.proxy.CGLIBLazyInitializer getProxyFactory
GRAVE: CGLIB Enhancement failed: org.im.utilisateurs.Utilisateurs
java.lang.NoClassDefFoundError: org/objectweb/asm/Type
	at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
	at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
	at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
	at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
	at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
	at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
	at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
	at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
	at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
	at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
	at org.im.utilitaire.HibernateUtility.<clinit>(HibernateUtility.java:15)
	at org.im.tests.Test.main(Test.java:18)
17 juil. 2006 21:33:07 org.hibernate.tuple.PojoEntityTuplizer buildProxyFactory
ATTENTION: could not create proxy factory for:org.im.utilisateurs.Utilisateurs
org.hibernate.HibernateException: CGLIB Enhancement failed: org.im.utilisateurs.Utilisateurs
	at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:132)
	at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
	at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
	at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
	at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
	at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
	at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
	at org.im.utilitaire.HibernateUtility.<clinit>(HibernateUtility.java:15)
	at org.im.tests.Test.main(Test.java:18)
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type
	at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
	at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
	at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
	at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
	... 13 more
17 juil. 2006 21:33:07 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
17 juil. 2006 21:33:07 org.hibernate.util.JDBCExceptionReporter logExceptions
ATTENTION: SQL Error: 0, SQLState: null
17 juil. 2006 21:33:07 org.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: L'élément du batch 0 insert into utilisateurs (nom, prenom, password, datecm, issupprimable, iduser) values (Martin, Jean, 1234, 2006-07-17 21:33:07.251000 +0200, 10, 1) a été annulé. Appeler getNextException pour en connaître la cause.
17 juil. 2006 21:33:07 org.hibernate.util.JDBCExceptionReporter logExceptions
ATTENTION: SQL Error: 0, SQLState: 23514
17 juil. 2006 21:33:07 org.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: ERREUR: La nouvelle ligne pour la relation «utilisateurs» viole la contrainte de vérification «utilisateurs_issupprimable_check»
17 juil. 2006 21:33:07 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
GRAVE: 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:202)
	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:297)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
	at org.im.tests.Test.main(Test.java:37)
Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into utilisateurs (nom, prenom, password, datecm, issupprimable, iduser) values (Martin, Jean, 1234, 2006-07-17 21:33:07.251000 +0200, 10, 1) a été annulé. Appeler getNextException pour en connaître la cause.
	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2512)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1310)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2574)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
	... 8 more
Exception in thread "main" 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:202)
	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:297)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
	at org.im.tests.Test.main(Test.java:37)
Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into utilisateurs (nom, prenom, password, datecm, issupprimable, iduser) values (Martin, Jean, 1234, 2006-07-17 21:33:07.251000 +0200, 10, 1) a été annulé. Appeler getNextException pour en connaître la cause.
	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2512)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1310)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2574)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
	... 8 more
Ci-joint mes fichiers de conf

-- hibernate.cfg.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
 
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
<hibernate-configuration>
    <session-factory >
 
 
 
		<!-- local connection properties -->
		<property name="hibernate.connection.url">jdbc:postgresql://192.168.0.1:5432/base</property>
		<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
		<property name="hibernate.connection.username">martin</property>
		<property name="hibernate.connection.password">test</property>
		<!-- property name="hibernate.connection.pool_size"></property -->
 
		<!-- dialect for PostgreSQL -->
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
 
        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
 
        <!-- mapping files -->
        <mapping resource="Utilisateurs.hbm.xml"/>
    </session-factory>
 
</hibernate-configuration>
-- Utilisateurs.hbm.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
34
35
36
 
 
<?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="org.im.utilisateurs">
 
	<class name="Utilisateurs" table="utilisateurs">
 
		<id name="iduser" type="integer">
            	<column name="iduser" sql-type="int(8)"/>
           		<generator class="increment"></generator>
        	</id>
 
		<property name="nom" type="string">
            		<column name="nom" length="40" not-null="true" />
        	</property>
 
		<property name="prenom" type="string">
            		<column name="prenom" length="40" not-null="true" />
        	</property>
 
		<property name="password" type="string">
            		<column name="password" length="20" not-null="true" />
        	</property>
 
		<property name="datecm" type="timestamp">
            		<column name="datecm" not-null="false" />
        	</property>
 
		<property name="issupprimable" type="integer">
            		<column name="issupprimable" length="4" not-null="true" />
        	</property>
 
    	</class>
 
</hibernate-mapping>
Auriez vous une idées ?

Cordialement,

@+ xarius