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 :

[Hibernate][error] Could not execute JDBC batch update


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Avatar de CPI_en_mousse
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2006
    Messages
    332
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 332
    Par défaut [Hibernate][error] Could not execute JDBC batch update
    Bonjour à tous,

    lors de l'execution d'une réquete j'ai 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
    exception 
    javax.servlet.ServletException: Could not execute JDBC batch update
        org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
        org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
        org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    cause mère 
    org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
        org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
        org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
        org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
        org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        be.qspin.qats.business.HibernateUtility.setRow(HibernateUtility.java:99)
        be.qspin.qats.business.Applicants.createApplicant(Applicants.java:53)
        be.qspin.qats.struts.action.CreateApplicantAction.execute(CreateApplicantAction.java:84)
        org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    le .hbm:
    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
    <hibernate-mapping default-lazy="false">
        <class name="be.qspin.qats.entities.Applicant" table="APPLICANTS">
            <meta attribute="class-description">
                Define an "Applicant" entity.
            </meta>
            <id name="id" type="integer" column="ID">
                <generator class="increment">
                </generator>            
            </id>
            <property name="lastname" type="string" not-null="true">
                <column name="LASTNAME" length="20" not-null="true"/>
            </property>
            <property name="firstname" type="string" not-null="true">
                <column name="FIRSTNANE" length="20" not-null="true"/>
            </property>
            <property name="gender" type="string" not-null="true">
                <column name="GENDER" length="20" not-null="true"/>
            </property>        
            <property name="birthday" type="timestamp" not-null="true">
                <column name="BIRTHDAY" length="20" not-null="true"/>
            </property>
            <property name="nationality" type="string" not-null="true">
                <column name="NATIONALITY" length="20" not-null="true"/>
            </property>
            <property name="address" type="string" not-null="true">
                <column name="ADDRESS" length="20" not-null="true"/>
            </property>
            <property name="PC" type="string" not-null="true">
                <column name="PC" length="20" not-null="true"/>
            </property>        
            <property name="city" type="string" not-null="true">
                <column name="CITY" length="20" not-null="true"/>
            </property>    
            <property name="country" type="string" not-null="true">
                <column name="COUNTRY" length="20" not-null="true"/>
            </property>  
            <property name="phone" type="string" not-null="true">
                <column name="PHONE" length="20" not-null="true"/>
            </property>    
            <property name="gsm" type="string" not-null="true">
                <column name="GSM" length="20" not-null="true"/>
            </property>  
            <property name="email" type="string" not-null="true">
                <column name="EMAIL" length="20" not-null="true"/>
            </property>   
            <property name="interest" type="string" not-null="true">
                <column name="INTEREST" length="1" not-null="true"/>
            </property>  
     
            <many-to-one name="jobTitle" column="TITLE" class="be.qspin.qats.entities.JobTitle" cascade="none" not-null="true"/>
     
        </class>
    </hibernate-mapping>
    le .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
     
        public static Applicant createApplicant(String lastname, String firstname, String selectJobTitle, String jobTitle, String interest, String gender, Date birthday, String nationality, String address, String PC, String city, String country, String phone, String gsm, String mail){
            Applicant appl = new Applicant();
            JobTitle jT = new JobTitle();
            jT.setTitle(jobTitle);
     
            appl.setLastname(lastname);
            appl.setFirstname(firstname);
            appl.setGender(gender);
            appl.setBirthday(birthday);
            appl.setNationality(nationality);
            appl.setAddress(address);
            appl.setPC(PC);
            appl.setCity(city);
            appl.setCountry(country);
            appl.setPhone(phone);
            appl.setGsm(gsm);
            appl.setEmail(mail);
     
            appl.setInterest(interest);
     
            System.out.println(appl.toString());
     
            if (selectJobTitle.equals("new"))
                HibernateUtility.setRow(jT);
            jT = (JobTitle) HibernateUtility.getRow(JobTitle.class, "title", jT.getTitle());
            appl.setJobTitle(jT);   
            HibernateUtility.setRow(appl); 
     
            return appl;
        }
    et l'insertion Hibernate :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
          public static void setRow(Object obj) {
            Session session = getHibernateSession();
            Transaction tx = session.beginTransaction();
            session.saveOrUpdate(obj);
            tx.commit();
            session.close();
        }
    pouvez vous m'aider et me dire d'ou vient l'erreur

    merci

  2. #2
    Membre éclairé
    Avatar de CPI_en_mousse
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2006
    Messages
    332
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 332
    Par défaut
    ha zut, je viens de m'apercevoir qu'il existe un forum Hibernate. comment faire pour déplacer son post?

  3. #3
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    365
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations forums :
    Inscription : Janvier 2006
    Messages : 365
    Par défaut
    Salut,
    Et si dans le mapping de "Applicant" tu mettais cascade="save-update" pour la relation many-to-one avec "JobTitle" ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <many-to-one name="jobTitle" column="TITLE" class="be.qspin.qats.entities.JobTitle" cascade="save-update" not-null="true"/>

  4. #4
    Membre éclairé
    Avatar de CPI_en_mousse
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2006
    Messages
    332
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 332
    Par défaut
    ca ne change rien, j'ai toujours la meme erreur

  5. #5
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    365
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations forums :
    Inscription : Janvier 2006
    Messages : 365
    Par défaut
    OK, alors le problème pourrait venir du fait que tu as not-null="true" dans cette relation many-to-one. Donc soit tu mets not-null=false, soit tu t'assures d'affecter un JobTitle à ton objet Applicant avant de le sauvegarder.
    Voilà, j'espère que ça t'avance à quelque chose.

  6. #6
    Membre éclairé
    Avatar de CPI_en_mousse
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2006
    Messages
    332
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 332
    Par défaut
    j'obtiens l'erreur suivante maintenant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    org.hibernate.PropertyValueException: not-null property references a null or transient value: be.qspin.qats.entities.JobTitle.title

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

Discussions similaires

  1. Réponses: 0
    Dernier message: 21/05/2009, 12h20
  2. Réponses: 1
    Dernier message: 30/09/2008, 17h13
  3. Could not execute JDBC batch update
    Par nabil148911 dans le forum Hibernate
    Réponses: 2
    Dernier message: 08/09/2007, 01h35
  4. Réponses: 5
    Dernier message: 01/08/2007, 15h07
  5. [EJB3] Could not execute JDBC batch update
    Par ®om dans le forum JPA
    Réponses: 18
    Dernier message: 07/03/2007, 11h59

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