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 :

problème avec hibernate


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Février 2008
    Messages
    686
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 686
    Par défaut problème avec hibernate
    salut ,j'ai un probleme avec hibernate
    j'obtient toujours 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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
     
    GRAVE: L'élément du batch 0 insert into NetAdmin.users (userName, password, name) values (Jean, pwd1, Dupont) a été annulé. Appeler getNextException pour en connaître la cause.
    27 oct. 2009 14:53:33 org.hibernate.util.JDBCExceptionReporter logExceptions
    ATTENTION: SQL Error: 0, SQLState: 3F000
    27 oct. 2009 14:53:33 org.hibernate.util.JDBCExceptionReporter logExceptions
    GRAVE: ERROR: schema "netadmin" does not exist
    27 oct. 2009 14:53:33 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
    GRAVE: Could not synchronize database state with session
    org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
    	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    	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:338)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    	at test.TestHibernate.main(TestHibernate.java:44)
    Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into NetAdmin.users (userName, password, name) values (Jean, pwd1, Dupont) a été annulé. Appeler getNextException pour en connaître la cause.
    	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2528)
    	at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:396)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1344)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:344)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2665)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    	... 8 more
    org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
    	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    	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:338)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    	at test.TestHibernate.main(TestHibernate.java:44)
    Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into NetAdmin.users (userName, password, name) values (Jean, pwd1, Dupont) a été annulé. Appeler getNextException pour en connaître la cause.
    	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2528)
    	at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:396)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1344)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:344)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2665)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    	... 8 more
    voici ma classe de test:
    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
     
    public class TestHibernate {
     
    	/**
             * @param args
             */
    	public static void main(String[] args) {
    		Session session = (Session) HibernateUtil.currentSession();
     
    		Transaction tx = session.beginTransaction();
     
    		Users contact = new Users();
    		contact.setName("Dupont");
    		contact.setUserName("Jean");
    		contact.setPassword("pwd1");
    		session.save(contact);
    	 try{  
    		tx.commit();
    		 }catch(Exception e)
    		 {
    			 e.printStackTrace();
    		 }
     
    		HibernateUtil.closeSession();
     
    	}
     
     
    }

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into NetAdmin.users (userName, password, name) values (Jean, pwd1, Dupont) a été annulé. Appeler getNextException pour en connaître la cause.
    sans avoir ce nextexception, difficile de trouver la cause. Il est possbile que tu viole un contraite quelconque de ton shéma de base de donnée, ou alors la table ou un colonne n'existe pas. essaie ce code éventuellement pour en savoir plus
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    catch(Exception e)
    		 {
    			 e.printStackTrace();
                             Throwabe t = e;
                             while (t.getCause()!=null)
                               t=t.getCause();
                              if (t instanceof SQLException){
                                ((SQLException)t).getNextException().printStackTrace();
                              }
    		 }

  3. #3
    Membre éclairé
    Inscrit en
    Février 2008
    Messages
    686
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 686
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    sans avoir ce nextexception, difficile de trouver la cause. Il est possbile que tu viole un contraite quelconque de ton shéma de base de donnée, ou alors la table ou un colonne n'existe pas. essaie ce code éventuellement pour en savoir plus
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    catch(Exception e)
    		 {
    			 e.printStackTrace();
                             Throwabe t = e;
                             while (t.getCause()!=null)
                               t=t.getCause();
                              if (t instanceof SQLException){
                                ((SQLException)t).getNextException().printStackTrace();
                              }
    		 }
    mefci tchize, j'ai inclus le code et lerreur généré est:
    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
     
    27 oct. 2009 15:39:53 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
    GRAVE: Could not synchronize database state with session
    org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    	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:338)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    	at test.TestHibernate.main(TestHibernate.java:33)
    Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into users (userName, password, name) values (Jean, pwd1, Dupont) a été annulé. Appeler getNextException pour en connaître la cause.
    	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2528)
    	at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:396)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1344)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:344)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2665)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    	... 8 more
    org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    	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:338)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    	at test.TestHibernate.main(TestHibernate.java:33)
    Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into users (userName, password, name) values (Jean, pwd1, Dupont) a été annulé. Appeler getNextException pour en connaître la cause.
    	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2528)
    	at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:396)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1344)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:344)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2665)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    	... 8 more
    org.postgresql.util.PSQLException: ERROR: relation "users" does not exist
    	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1608)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1343)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:344)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2665)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    	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:338)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    	at test.TestHibernate.main(TestHibernate.java:33)

  4. #4
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Comme indiqué
    org.postgresql.util.PSQLException: ERROR: relation "users" does not exist
    la table "users" n'existe pas dans ta base de données.

  5. #5
    Membre éclairé
    Inscrit en
    Février 2008
    Messages
    686
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 686
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    Comme indiqué la table "users" n'existe pas dans ta base de données.
    la table users existe bien
    en effet elle appartient à un shema et voici le fichier de mapping pour cette table:
    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
     
    <?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="tn.com.tradenet.netadmin.hibernate">
    	<class name="Users" table="users">
    		<id
    			column="name"
    			name="Name"
    			type="string"
    		>
     
    		</id>
    		<property
    			column="userName"
    			name="UserName"
    			not-null="true"
    			type="string"
    		 />
    		<property
    			column="password"
    			name="Password"
    			not-null="true"
    			type="string"
    		 />
    		<set inverse="true" name="ComptesSet">
    			<key column="userName" />
    			<one-to-many class="Comptes" />
    		</set>
    	</class>
    </hibernate-mapping>

  6. #6
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Citation Envoyé par riadhhwajdii Voir le message
    la table users existe bien
    en effet elle appartient à un shema et voici le fichier de mapping pour cette table:
    Ce n'est pas ce que dit postgres dans son message, es-tu sur de te connecter à la bonne base?

Discussions similaires

  1. Problème avec hibernate et MySQL!
    Par sofien dans le forum Outils
    Réponses: 5
    Dernier message: 27/08/2008, 09h06
  2. Les problémes avec Hibernate
    Par hichem_enis dans le forum Struts 1
    Réponses: 7
    Dernier message: 11/04/2008, 13h00
  3. Problème avec Hibernate
    Par ISID dans le forum Hibernate
    Réponses: 13
    Dernier message: 05/10/2007, 12h27
  4. Problème avec Hibernate synchronizer
    Par jason69 dans le forum Hibernate
    Réponses: 2
    Dernier message: 27/08/2007, 11h35
  5. [Hibernate] Problème avec Hibernate et Eclipse 3
    Par theseuby dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 30/03/2006, 21h31

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