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

Tomcat et TomEE Java Discussion :

[Hibernate][Tomcat] Select sur tables


Sujet :

Tomcat et TomEE Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    129
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 129
    Par défaut [Hibernate][Tomcat] Select sur tables
    Hello,

    Voici mon problème, je développe donc un webservice en utilisant les technologies suivantes :
    - Eclipse.
    - Tomcat.
    - Hibernate.
    - MySql.

    Je mappe donc les tables à l'aide d'hibernate.
    Et quand je fais un select sur certaines tables j'obtiens des valeurs NULL, alors que la table contient des valeurs.
    Mais pour d'autres pas de problème.

    Le problème pourrait-il venir du mapping des tables ? Si les tables ont mal été créées ?

    Merci

  2. #2
    Membre expérimenté
    Inscrit en
    Mai 2005
    Messages
    217
    Détails du profil
    Informations personnelles :
    Âge : 43

    Informations forums :
    Inscription : Mai 2005
    Messages : 217
    Par défaut
    O_O ca va etre du de t'aider la :/

    Je precise le message initiale etait

    Citation Envoyé par parasol007
    Hello,

    Voici mon problème, je développe donc un webservice en utilisant les technologies suivantes :
    Mais il a ete edité
    ____

    Maintenant on va pouvoir t'aider

  3. #3
    Membre émérite Avatar de BizuR
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    688
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 688
    Par défaut
    peux tu afficher ton mapping (qui pose probleme tant qu'a faire) et le code qui l'utilise ... et par la même occasion, bah affiche aussi tes classe (classe+attributs seulement) ... histoire que l'on regarde ce qui peut se passer

  4. #4
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    129
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 129
    Par défaut Ok
    Oki merci
    C'est parti :

    Voici le fichier Candidat.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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Generated 11 mai 2006 16:11:59 by Hibernate Tools 3.1.0.beta5 -->
    <hibernate-mapping>
    <class name="com.artemis.models.Candidat" table="candidat" catalog="artemis">
    <comment></comment>
    <id name="canId" type="int">
    <column name="can_id" />
    <generator class="assigned" />
    </id>
    <many-to-one name="statutCandidat" class="com.artemis.models.StatutCandidat" fetch="select">
    <column name="sta_can_id">
    <comment></comment>
    </column>
    </many-to-one>
    <many-to-one name="origineCandidature" class="com.artemis.models.OrigineCandidature" fetch="select">
    <column name="ori_can_id">
    <comment></comment>
    </column>
    </many-to-one>
    <many-to-one name="categorie" class="com.artemis.models.Categorie" fetch="select">
    <column name="cat_id">
    <comment></comment>
    </column>
    </many-to-one>
    <many-to-one name="poste" class="com.artemis.models.Poste" fetch="select">
    <column name="pos_id">
    <comment></comment>
    </column>
    </many-to-one>
    <many-to-one name="region" class="com.artemis.models.Region" fetch="select">
    <column name="reg_id">
    <comment></comment>
    </column>
    </many-to-one>
    <property name="canNom" type="string">
    <column name="can_nom" length="45" not-null="true">
    <comment></comment>
    </column>
    </property>
    <property name="canPrenom" type="string">
    <column name="can_prenom" length="45" not-null="true">
    <comment></comment>
    </column>
    </property>
    <property name="canMail" type="string">
    <column name="can_mail" length="45" not-null="true">
    <comment></comment>
    

  5. #5
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    129
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 129
    Par défaut
    la suite
    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
    </column>
    </property>
    <property name="canLienCv" type="string">
    <column name="can_lien_cv" length="45">
    <comment></comment>
    </column>
    </property>
    <property name="canDateCreation" type="date">
    <column name="can_date_creation" length="10" not-null="true">
    <comment></comment>
    </column>
    </property>
    <property name="canCommentaires" type="string">
    <column name="can_commentaires" length="65535">
    <comment></comment>
    </column>
    </property>
    <property name="canMailEnvoye" type="java.lang.Integer">
    <column name="can_mail_envoye">
    <comment></comment>
    </column>
    </property>
    <property name="canDateCvAnalyse" type="date">
    <column name="can_date_cv_analyse" length="10" not-null="true">
    <comment></comment>
    </column>
    </property>
    <property name="canStatutInfos" type="string">
    <column name="can_statut_infos" length="45">
    <comment></comment>
    </column>
    </property>
    <set name="candComps" inverse="true">
    <key>
    <column name="can_id" not-null="true">
    <comment></comment>
    </column>
    </key>
    <one-to-many class="com.artemis.models.CandComp" />
    </set>
    <set name="candDemaUtils" inverse="true">
    <key>
    <column name="can_id" not-null="true">
    <comment></comment>
    </column>
    </key>
    <one-to-many class="com.artemis.models.CandDemaUtil" />
    </set>
    <set name="candOffrUtils" inverse="true">
    <key>
    <column name="can_id" not-null="true">
    <comment></comment>
    </column>
    </key>
    <one-to-many class="com.artemis.models.CandOffrUtil" />
    </set>
    </class>
    </hibernate-mapping>
    
    [/code]

  6. #6
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    129
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 129
    Par défaut Comme promis ...lol
    La classe permettant de lister les candidats

    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
     
    import java.util.Enumeration;
    import java.util.Iterator;
    import java.util.List;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /*
     * 
     *
     */
    public  class ListeCandidats extends HttpServlet
    {
     
     /**
      * 
      */
     private static final long serialVersionUID = 1L;
     
     public void doPost( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException
        {
      PrintWriter out=res.getWriter();
     
       HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
       List result = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(Candidat.class).list();
            if (result.size() > 0) {
                 for (Iterator it = result.iterator(); it.hasNext();) {
                     Candidat can = (Candidat) it.next();
                     out.print(can.getCanNom());
                     }
          }
     
     
     
        }
        public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException
        {
              doPost(req,res);  
        }
    }

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

Discussions similaires

  1. Problème select sur table/vue x$ksppsv
    Par LBO72 dans le forum Administration
    Réponses: 4
    Dernier message: 25/03/2009, 09h07
  2. INSERT / SELECT sur tables multiples
    Par AlexisB dans le forum Langage SQL
    Réponses: 2
    Dernier message: 03/11/2008, 15h17
  3. Select sur table de jointure qui pointe sur la meme Table.
    Par yakamax dans le forum Langage SQL
    Réponses: 2
    Dernier message: 25/06/2008, 11h44
  4. Réponses: 7
    Dernier message: 28/01/2008, 10h43
  5. Insert avec select sur table avec Trigger d'insertion
    Par bran_noz dans le forum Développement
    Réponses: 5
    Dernier message: 23/12/2005, 14h38

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