Quantcast

Can't read multiple rows from the database

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Can't read multiple rows from the database

batisbatis
This post has NOT been accepted by the mailing list yet.
Hi everyone,
well, I'm trying to read multiple rows from one of the tables of my database, i'm working with this code to extract them alla ant put them in a list:


==================================================================

    public ArrayList<CollaborateurVO> getAllCollaborateur() {
        SqlSession session = sf.openSession();
        try {
            log.info("Access to database");
           
            ArrayList<CollaborateurVO> collaborateurs = (ArrayList<CollaborateurVO>) session.selectList("com.pgp.xmlMapper.CollaborateurVOMapper.allCollaborateur");
           
    for(int i=0; i<collaborateurs.size();i++)
    log.error(" -----> nom: "+collaborateurs.get(i).getNomCollaborateur() +" :: prenom :"+collaborateurs.get(i).getPrenomCollaborateur()+" :: poste: "+collaborateurs.get(i).getSpetialiteCollaborateur()+" :: mail: "+collaborateurs.get(i).getEmailCollaborateur()+"  :: tel: "+collaborateurs.get(i).getTelephoneCollaborateur());
   
           
            return collaborateurs;
        } finally {
           
            session.close();
        }
    }

==================================================================



And in the log I'm getting:



==================================================================

Infos: 11:52:49.870 [http-thread-pool-8080(3)] DEBUG java.sql.PreparedStatement - ==>  Executing: select * from collaborateur


Infos: 11:52:49.409 [http-thread-pool-8080(3)] INFO  com.pgp.mybatisDAO.MyBatisDAO - Access to database

Infos: 11:52:49.870 [http-thread-pool-8080(3)] DEBUG java.sql.PreparedStatement - ==> Parameters:

Infos: 11:52:49.906 [http-thread-pool-8080(3)] DEBUG java.sql.ResultSet - <==    Columns: ID_COLLABORATEUR, NOM, PRENOM, PASSWD, SPETIALITE, TELEPHONE, EMAIL, ADRESSE, EST_CHEF

Infos: 11:52:49.907 [http-thread-pool-8080(3)] DEBUG java.sql.ResultSet - <==        Row: 1, Farouti, Ahmed, Ahmed, Developpement, 20986536, fourati.ahmed@gmail.com, Rue 2097, 1

Infos: 11:52:49.908 [http-thread-pool-8080(3)] DEBUG java.sql.ResultSet - <==        Row: 2, Saddéli, Ali, Ali, Test, 99645256, saddeli.ali@gmail.com, Rue 5234, 0

Infos: 11:52:49.909 [http-thread-pool-8080(3)] DEBUG java.sql.ResultSet - <==        Row: 3, Talléd, Mohamed, Mohamed, Concepteur, 24875735, talled.mohamed@gmail.com, Rue 2580, 0

Infos: 11:52:49.909 [http-thread-pool-8080(3)] ERROR com.pgp.mybatisDAO.MyBatisDAO -  -----> nom: null :: prenom :null :: poste: null :: mail: null  :: tel: null

Infos: 11:52:49.910 [http-thread-pool-8080(3)] ERROR com.pgp.mybatisDAO.MyBatisDAO -  -----> nom: null :: prenom :null :: poste: null :: mail: null  :: tel: null

Infos: 11:52:49.910 [http-thread-pool-8080(3)] ERROR com.pgp.mybatisDAO.MyBatisDAO -  -----> nom: null :: prenom :null :: poste: null :: mail: null  :: tel: null

==================================================================


Data is actually coming out of the database, the list has the correct size but when I try to read from it, all attributes are null !!!

I could not see where is the error.

Here is the mapper of this table:

==================================================================

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pgp.xmlMapper.CollaborateurVOMapper" >
  <resultMap id="BaseResultMap" type="com.pgp.persistance.vo.CollaborateurVO" >
   
    <id column="ID_COLLABORATEUR" property="ID_COLLABORATEUR" jdbcType="INTEGER" />
    <result column="NOM_COLLABORATEUR" property="nomCollaborateur" jdbcType="VARCHAR" />
    <result column="PRENOM_COLLABORATEUR" property="prenomCollaborateur" jdbcType="VARCHAR" />
    <result column="PASSWD_COLLABORATEUR" property="passwdCollaborateur" jdbcType="VARCHAR" />
    <result column="SPETIALITE_COLLABORATEUR" property="spetialiteCollaborateur" jdbcType="VARCHAR" />
    <result column="TELEPHONE_COLLABORATEUR" property="telephoneCollaborateur" jdbcType="VARCHAR" />
    <result column="EMAIL_COLLABORATEUR" property="emailCollaborateur" jdbcType="VARCHAR" />
    <result column="ADRESSE_COLLABORATEUR" property="adresseCollaborateur" jdbcType="VARCHAR" />
    <result column="EST_CHEF" property="estChef" jdbcType="INTEGER" />
  </resultMap>
 
  <select id="allCollaborateur" resultMap="BaseResultMap">
        select * from collaborateur
 </select>
 
  <sql id="Example_Where_Clause" >
   
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
   
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
   
    ID_COLLABORATEUR, NOM_COLLABORATEUR, PRENOM_COLLABORATEUR, PASSWD_COLLABORATEUR,
    SPETIALITE_COLLABORATEUR, TELEPHONE_COLLABORATEUR, EMAIL_COLLABORATEUR, ADRESSE_COLLABORATEUR,
    EST_CHEF
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.pgp.persistance.vo.CollaborateurVOExample" >
   
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from pgp..collaborateur
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from pgp..collaborateur
    where ID_COLLABORATEUR = #{ID_COLLABORATEUR,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from pgp..collaborateur
    where ID_COLLABORATEUR = #{ID_COLLABORATEUR,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.pgp.persistance.vo.CollaborateurVOExample" >
    delete from pgp..collaborateur
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.pgp.persistance.vo.CollaborateurVO" >
    insert into pgp..collaborateur (ID_COLLABORATEUR, NOM_COLLABORATEUR,
      PRENOM_COLLABORATEUR, PASSWD_COLLABORATEUR,
      SPETIALITE_COLLABORATEUR, TELEPHONE_COLLABORATEUR,
      EMAIL_COLLABORATEUR, ADRESSE_COLLABORATEUR,
      EST_CHEF)
    values (#{ID_COLLABORATEUR,jdbcType=INTEGER}, #{nomCollaborateur,jdbcType=VARCHAR},
      #{prenomCollaborateur,jdbcType=VARCHAR}, #{passwdCollaborateur,jdbcType=VARCHAR},
      #{spetialiteCollaborateur,jdbcType=VARCHAR}, #{telephoneCollaborateur,jdbcType=VARCHAR},
      #{emailCollaborateur,jdbcType=VARCHAR}, #{adresseCollaborateur,jdbcType=VARCHAR},
      #{estChef,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.pgp.persistance.vo.CollaborateurVO" >
    insert into pgp..collaborateur
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="ID_COLLABORATEUR != null" >
        ID_COLLABORATEUR,
      </if>
      <if test="nomCollaborateur != null" >
        NOM_COLLABORATEUR,
      </if>
      <if test="prenomCollaborateur != null" >
        PRENOM_COLLABORATEUR,
      </if>
      <if test="passwdCollaborateur != null" >
        PASSWD_COLLABORATEUR,
      </if>
      <if test="spetialiteCollaborateur != null" >
        SPETIALITE_COLLABORATEUR,
      </if>
      <if test="telephoneCollaborateur != null" >
        TELEPHONE_COLLABORATEUR,
      </if>
      <if test="emailCollaborateur != null" >
        EMAIL_COLLABORATEUR,
      </if>
      <if test="adresseCollaborateur != null" >
        ADRESSE_COLLABORATEUR,
      </if>
      <if test="estChef != null" >
        EST_CHEF,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="ID_COLLABORATEUR != null" >
        #{ID_COLLABORATEUR,jdbcType=INTEGER},
      </if>
      <if test="nomCollaborateur != null" >
        #{nomCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="prenomCollaborateur != null" >
        #{prenomCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="passwdCollaborateur != null" >
        #{passwdCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="spetialiteCollaborateur != null" >
        #{spetialiteCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="telephoneCollaborateur != null" >
        #{telephoneCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="emailCollaborateur != null" >
        #{emailCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="adresseCollaborateur != null" >
        #{adresseCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="estChef != null" >
        #{estChef,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.pgp.persistance.vo.CollaborateurVOExample" resultType="java.lang.Integer" >
    select count(*) from pgp..collaborateur
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update pgp..collaborateur
    <set >
      <if test="record.ID_COLLABORATEUR != null" >
        ID_COLLABORATEUR = #{record.ID_COLLABORATEUR,jdbcType=INTEGER},
      </if>
      <if test="record.nomCollaborateur != null" >
        NOM_COLLABORATEUR = #{record.nomCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.prenomCollaborateur != null" >
        PRENOM_COLLABORATEUR = #{record.prenomCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.passwdCollaborateur != null" >
        PASSWD_COLLABORATEUR = #{record.passwdCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.spetialiteCollaborateur != null" >
        SPETIALITE_COLLABORATEUR = #{record.spetialiteCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.telephoneCollaborateur != null" >
        TELEPHONE_COLLABORATEUR = #{record.telephoneCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.emailCollaborateur != null" >
        EMAIL_COLLABORATEUR = #{record.emailCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.adresseCollaborateur != null" >
        ADRESSE_COLLABORATEUR = #{record.adresseCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="record.estChef != null" >
        EST_CHEF = #{record.estChef,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update pgp..collaborateur
    set ID_COLLABORATEUR = #{record.ID_COLLABORATEUR,jdbcType=INTEGER},
      NOM_COLLABORATEUR = #{record.nomCollaborateur,jdbcType=VARCHAR},
      PRENOM_COLLABORATEUR = #{record.prenomCollaborateur,jdbcType=VARCHAR},
      PASSWD_COLLABORATEUR = #{record.passwdCollaborateur,jdbcType=VARCHAR},
      SPETIALITE_COLLABORATEUR = #{record.spetialiteCollaborateur,jdbcType=VARCHAR},
      TELEPHONE_COLLABORATEUR = #{record.telephoneCollaborateur,jdbcType=VARCHAR},
      EMAIL_COLLABORATEUR = #{record.emailCollaborateur,jdbcType=VARCHAR},
      ADRESSE_COLLABORATEUR = #{record.adresseCollaborateur,jdbcType=VARCHAR},
      EST_CHEF = #{record.estChef,jdbcType=INTEGER}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.pgp.persistance.vo.CollaborateurVO" >
    update pgp..collaborateur
    <set >
      <if test="nomCollaborateur != null" >
        NOM_COLLABORATEUR = #{nomCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="prenomCollaborateur != null" >
        PRENOM_COLLABORATEUR = #{prenomCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="passwdCollaborateur != null" >
        PASSWD_COLLABORATEUR = #{passwdCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="spetialiteCollaborateur != null" >
        SPETIALITE_COLLABORATEUR = #{spetialiteCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="telephoneCollaborateur != null" >
        TELEPHONE_COLLABORATEUR = #{telephoneCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="emailCollaborateur != null" >
        EMAIL_COLLABORATEUR = #{emailCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="adresseCollaborateur != null" >
        ADRESSE_COLLABORATEUR = #{adresseCollaborateur,jdbcType=VARCHAR},
      </if>
      <if test="estChef != null" >
        EST_CHEF = #{estChef,jdbcType=INTEGER},
      </if>
    </set>
    where ID_COLLABORATEUR = #{ID_COLLABORATEUR,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pgp.persistance.vo.CollaborateurVO" >
    update pgp..collaborateur
    set NOM_COLLABORATEUR = #{nomCollaborateur,jdbcType=VARCHAR},
      PRENOM_COLLABORATEUR = #{prenomCollaborateur,jdbcType=VARCHAR},
      PASSWD_COLLABORATEUR = #{passwdCollaborateur,jdbcType=VARCHAR},
      SPETIALITE_COLLABORATEUR = #{spetialiteCollaborateur,jdbcType=VARCHAR},
      TELEPHONE_COLLABORATEUR = #{telephoneCollaborateur,jdbcType=VARCHAR},
      EMAIL_COLLABORATEUR = #{emailCollaborateur,jdbcType=VARCHAR},
      ADRESSE_COLLABORATEUR = #{adresseCollaborateur,jdbcType=VARCHAR},
      EST_CHEF = #{estChef,jdbcType=INTEGER}
    where ID_COLLABORATEUR = #{ID_COLLABORATEUR,jdbcType=INTEGER}
  </update>
</mapper>


==================================================================


Can any one help me please ??
Loading...