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 :

messages d'erreurs / exception


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Juin 2007
    Messages
    328
    Détails du profil
    Informations forums :
    Inscription : Juin 2007
    Messages : 328
    Par défaut messages d'erreurs / exception
    Bonsoir
    Lors de l'excection , on m'affiche ces exceptions la
    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
     
    Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.gh.model.Personnel]
    	at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1777)
    	at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2178)
    	at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)
    	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
    	at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:240)
    	at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
    	at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)
    	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
    	at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
    	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
    	at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
    	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
    	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
    	at com.gh.service.PersonnelService.ajouterPersonnel(PersonnelService.java:18)
    	at com.gh.model.Application.main(Application.java:48)
    Caused by: java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p, PRENOM_P, CIN_P, TEL_P, DATE_EMBAUCHE, MAIL_P, ADRESSE_P, DATE_NAISSANCE_P, C' at line 1"
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
    	at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
    	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1772)
    	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1619)
    	at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1759)
    	... 15 more
    J'ai tt verifié ( les types des variables ..) mais ca marche tjrs pas

  2. #2
    Membre Expert
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Par défaut
    Ben avec le preparedStatement que tu essayes d'exécuter ca serait surement plus simple pour t'aider ...

  3. #3
    Membre éclairé
    Inscrit en
    Juin 2007
    Messages
    328
    Détails du profil
    Informations forums :
    Inscription : Juin 2007
    Messages : 328
    Par défaut
    C quoi un preparedStatment ?

  4. #4
    Membre Expert
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Par défaut
    Oups j'ai lu trop vite dsl ...
    En fait ce dont on aurait besoin c'est de ta classe Personne1 et de son fichier de mapping ainsi que de la structure de la table correspondante ...

  5. #5
    Membre éclairé
    Inscrit en
    Juin 2007
    Messages
    328
    Détails du profil
    Informations forums :
    Inscription : Juin 2007
    Messages : 328
    Par défaut
    Personne.java:
    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
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
     
    package com.gh.model;
     
    import java.util.*;
     
     
    public class Personnel extends BaseObject
    {
       private String nom_p;
       private String prenom_p;
       private String cin_p;
       private String tel_p;
       private Date date_embauche;
       private String mail_p;
       private String adresse_p;
       private Date date_naissance_p;
       private String civilite_p;
       private String etat_civil_p;
       private String cnss;
       private String cimr;
       private Integer matricule_p;
       private Fonction fonction;
     
    public String getAdresse_p() {
    	return adresse_p;
    }
     
    public void setAdresse_p(String adresse_p) {
    	this.adresse_p = adresse_p;
    }
     
    public String getCimr() {
    	return cimr;
    }
     
    public void setCimr(String cimr) {
    	this.cimr = cimr;
    }
     
    public String getCin_p() {
    	return cin_p;
    }
     
    public void setCin_p(String cin_p) {
    	this.cin_p = cin_p;
    }
     
    public String getCivilite_p() {
    	return civilite_p;
    }
     
    public void setCivilite_p(String civilite_p) {
    	this.civilite_p = civilite_p;
    }
     
    public String getCnss() {
    	return cnss;
    }
     
    public void setCnss(String cnss) {
    	this.cnss = cnss;
    }
     
     
     
    public Date getDate_embauche() {
    	return date_embauche;
    }
     
    public void setDate_embauche(Date date_embauche) {
    	this.date_embauche = date_embauche;
    }
     
    public Date getDate_naissance_p() {
    	return date_naissance_p;
    }
     
    public void setDate_naissance_p(Date date_naissance_p) {
    	this.date_naissance_p = date_naissance_p;
    }
     
    public String getEtat_civil_p() {
    	return etat_civil_p;
    }
     
    public void setEtat_civil_p(String etat_civil_p) {
    	this.etat_civil_p = etat_civil_p;
    }
     
    public Fonction getFonction() {
    	return fonction;
    }
     
    public void setFonction(Fonction fonction) {
    	this.fonction = fonction;
    }
     
    public String getMail_p() {
    	return mail_p;
    }
     
    public void setMail_p(String mail_p) {
    	this.mail_p = mail_p;
    }
     
    public String getNom_p() {
    	return nom_p;
    }
     
    public void setNom_p(String nom_p) {
    	this.nom_p = nom_p;
    }
     
    public String getPrenom_p() {
    	return prenom_p;
    }
     
    public void setPrenom_p(String prenom_p) {
    	this.prenom_p = prenom_p;
    }
     
    public String getTel_p() {
    	return tel_p;
    }
     
    public void setTel_p(String tel_p) {
    	this.tel_p = tel_p;
    }
     
    public Integer getMatricule_p() {
    	return matricule_p;
    }
     
    public void setMatricule_p(Integer matricule_p) {
    	this.matricule_p = matricule_p;
    }
     
    }
    Personnel.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
     
    <hibernate-mapping package="com.gh.model">
     <class name="Personnel" table="personnel">
      <id name="matricule_p" column="MATRICULE_P" type="java.lang.Integer">
            <generator class="native"/>
       </id>
     
    <property name="nom_p" column="NOM_	p" type="java.lang.String"/>
    <property name="prenom_p" column="PRENOM_P" type="java.lang.String"/>
    <property name="cin_p" column="CIN_P" type="java.lang.String"/>
    <property name="tel_p" column="TEL_P" type="java.lang.String"/>
    <property name="date_embauche" column="DATE_EMBAUCHE" type="java.util.Date"/>
    <property name="mail_p" column="MAIL_P" type="java.lang.String"/>
    <property name="adresse_p" column="ADRESSE_P" type="java.lang.String"/>
    <property name="date_naissance_p" column="DATE_NAISSANCE_P" type="java.util.Date"/>
    <property name="civilite_p" column="CIVILITE_P" type="java.lang.String"/>
    <property name="etat_civil_p" column="ETAT_CIVIL_P" type="java.lang.String"/>
    <property name="cnss" column="CNSS_P" type="java.lang.String"/>
    <property name="cimr" column="CIMR_P" type="java.lang.String"/>
     
     
     
     <many-to-one name="fonction"  column="CODE_F" class="Fonction" not-null="true"/>
     
      </class>
    </hibernate-mapping>
    La table Personnel :
    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
     
     
    /*==============================================================*/
    /* Table : PERSONNEL                                            */
    /*==============================================================*/
    create table PERSONNEL
    (
       MATRICULE_P                    int                            not null,
       CODE_F                         int                            not null,
       NOM_P                          varchar(50),
       PRENOM_P                       varchar(50),
       CIN_P                          varchar(50),
       TEL_P                          varchar(50),
       DATE_EMBAUCHE                  date,
       MAIL_P                         varchar(50),
       ADRESSE_P                      varchar(50),
       DATE_NAISS_P                   date,
       CIVILITE_P                     varchar(50),
       ETAT_CIVIL_P                   varchar(50),
       CIMR                           varchar(50),
       CNSS                           varchar(50),
       primary key (MATRICULE_P)
    );
     
    /*==============================================================*/
    /* Index : PERSONNEL_PK                                         */
    /*==============================================================*/
    create unique index PERSONNEL_PK on PERSONNEL
    (
       MATRICULE_P
    );
     
    /*==============================================================*/
    /* Index : APPARTENIR_FK                                        */
    /*==============================================================*/
    create index APPARTENIR_FK on PERSONNEL
    (
       CODE_F
    );

  6. #6
    Membre expérimenté Avatar de Sceener
    Inscrit en
    Mai 2007
    Messages
    231
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 231
    Par défaut
    Moi , je pense à un rejet base de donnée de ton insert , la tabel personnelm n'a pas de lien avec d'autres table dans ta BD ?

  7. #7
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 276
    Par défaut
    <property name="nom_p" column="NOM_ p" type="java.lang.String"/>
    C'est normal la tabulation entre NOM_ et p ?

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

Discussions similaires

  1. message d'erreur "except NameError" ne fonctionne pas
    Par lamwat dans le forum Général Python
    Réponses: 5
    Dernier message: 24/04/2014, 18h50
  2. message d'erreur : Exception [EclipseLink-4002]
    Par drsbmm dans le forum NetBeans
    Réponses: 0
    Dernier message: 16/03/2014, 12h06
  3. Réponses: 6
    Dernier message: 07/04/2011, 10h57
  4. Message d'erreur "Exception"
    Par nefertari dans le forum Delphi
    Réponses: 4
    Dernier message: 29/05/2007, 13h28
  5. [Message d'erreur] Classe d'exception
    Par Pascal dans le forum Bases de données
    Réponses: 4
    Dernier message: 23/05/2004, 10h08

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