You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jdev <jd...@telenet.be> on 2007/07/22 16:41:08 UTC

Problem with nullpointerException

Can someone explain me how I get the code mentioned below running?
The problem is that it concerns a list and I don't know correct how I get it
to work, the code that I developed gives me each time a nullpointerexception
when I run it.
Can someone give me some information about what I do wrong?
 
 
public RowBeheer[] readBeheerList1(String ondnr) {
    
    RowBeheer[] rowBeheer = null;
    
    try {
      dao.BeheerDAO beheerDao = (dao.BeheerDAO)
DaoManagerRequester.getDaoManager().getDao(dao.BeheerDAO.class);
      model.BeheerExample beheerExample = new model.BeheerExample();
      beheerExample.createCriteria().andReferentienummerLike(likesleutel);
      List resultList = beheerDao.selectByExample(beheerExample);
      
      if (resultList.size() > 0) {
        for(int i = 0; i < resultList.size(); i++) {
          rowBeheer[i] = new RowBeheer();
          model.Beheer beheer = (model.Beheer) resultList.get(i);      
          rowBeheer[i].setReferentienummer(beheer.getReferentienummer());
          rowBeheer[i].setVolgnr(beheer.getVolgnr());
 
rowBeheer[i].setRowdatumbegin(String.valueOf(beheer.getRowdatumbegin()));
 
rowBeheer[i].setRowdatumeinde(String.valueOf(beheer.getRowdatumeinde()));
          rowBeheer[i].setKantoorcode(beheer.getKantoorcode());
          rowBeheer[i].setDossierstatus(beheer.getDossierstatus());
          return rowBeheer;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
 
 

Re: Problem with nullpointerException

Posted by Ashok Madhavan <as...@gmail.com>.
dude,
rowBeheer has not been initialized. use a List instead.

ashok

On 7/22/07, Jdev <jd...@telenet.be> wrote:
>
>  Can someone explain me how I get the code mentioned below running?
>
> The problem is that it concerns a list and I don't know correct how I get
> it to work, the code that I developed gives me each time a
> nullpointerexception when I run it.
>
> Can someone give me some information about what I do wrong?
>
>
>
>
>
> public RowBeheer[] readBeheerList1(String ondnr) {
>
>
>
>     RowBeheer[] rowBeheer = null;
>
>
>
>     try {
>
>       dao.BeheerDAO beheerDao = (dao.BeheerDAO)
> DaoManagerRequester.getDaoManager().getDao(dao.BeheerDAO.class);
>
>       model.BeheerExample beheerExample = new model.BeheerExample();
>
>       beheerExample.createCriteria().andReferentienummerLike(likesleutel);
>
>       List resultList = beheerDao.selectByExample(beheerExample);
>
>
>
>       if (resultList.size() > 0) {
>
>         for(int i = 0; i < resultList.size(); i++) {
>
>           rowBeheer[i] = new RowBeheer();
>
>           model.Beheer beheer = (model.Beheer) resultList.get(i);
>
>           rowBeheer[i].setReferentienummer(beheer.getReferentienummer());
>
>           rowBeheer[i].setVolgnr(beheer.getVolgnr());
>
>           rowBeheer[i].setRowdatumbegin(String.valueOf(beheer.
> getRowdatumbegin()));
>
>           rowBeheer[i].setRowdatumeinde(String.valueOf(beheer.
> getRowdatumeinde()));
>
>           rowBeheer[i].setKantoorcode(beheer.getKantoorcode());
>
>           rowBeheer[i].setDossierstatus(beheer.getDossierstatus());
>
>           return rowBeheer;
>
>         }
>
>       }
>
>     } catch (Exception e) {
>
>       e.printStackTrace();
>
>     }
>
>     return null;
>
>   }
>
>
>
>
>