IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

[Utilisation d'Hibernate + probleme de conf]


Sujet :

Hibernate Java

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 38
    Par défaut [Utilisation d'Hibernate + probleme de conf]
    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

  2. #2
    Membre Expert
    Avatar de zekey
    Profil pro
    Inscrit en
    Février 2005
    Messages
    1 036
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 1 036
    Par défaut
    Tout d'abord il te manque un jar qui s'appelle asm-1.5.2.jar (peut être une autre version selon ta ditrib) dans ton classpath

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 38
    Par défaut
    Ok merci, cela fonctionne mieux effectivement.

    @+ xarius

  4. #4
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    59
    Détails du profil
    Informations personnelles :
    Âge : 45

    Informations forums :
    Inscription : Avril 2006
    Messages : 59
    Par défaut
    Bonjour,

    j'ai exactement le même problème que Xarius mais j'ai bien vérifié dans java build path, la librairie en question s'y trouve bien.
    Quelqu'un aurait-il une autre idée ?

    merci d'avance pour votre aide.

    Bone journée

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Hibernate] Problemes de connexion d'un sous domaine
    Par sylvain_neus dans le forum Hibernate
    Réponses: 15
    Dernier message: 09/05/2006, 10h49
  2. [hibernate] probleme à la compilation sous eclipse
    Par ejaub dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 23/11/2005, 10h45
  3. [Hibernate] Problème de sauvegarde
    Par lilou77 dans le forum Hibernate
    Réponses: 15
    Dernier message: 26/10/2005, 11h17
  4. [Hibernate] Problème de clé composite
    Par esteban dans le forum Hibernate
    Réponses: 3
    Dernier message: 01/09/2005, 17h12
  5. [Hibernate]Probleme de requete avec un "or"[\Hiber
    Par crips dans le forum Hibernate
    Réponses: 5
    Dernier message: 07/07/2005, 03h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo