1 Reply Latest reply on Jun 18, 2004 3:30 AM by aloubyansky

    why findAll() method retuning  unusual result

    nischalsharma

      hi

      friends

      i am getting very unusual result while running findAll() method of my
      cmp bean.

      for example :if there are 3 record in database then final output show the
      last record 3 three times. ie end record display three time.


      here is the code :function with findAll()
      ------------------------------------------

      public ArrayList getPassportProfile(Long pk) throws NamingException, FinderException
      {

      try{
      CandidatePassportLocal candidatePassportLocal;
      CandidatePassportLocalHome candidatePassportLocalHome = this.getCandidatePassportLocalHome();

      Collection result = candidatePassportLocalHome.findAll();
      ArrayList list =new ArrayList(result) ;
      System.out.println("------result.size()--------"+result.size());
      if(result.size()==0) {
      System.out.println("3");
      return list;
      }
      else
      {

      for(int i=0;i<list.size();i++)
      {
      candidatePassportLocal = (CandidatePassportLocal)list.get(i);
      System.out.println(" candidatePassportLocal.getPassportNo()-->"+ candidatePassportLocal.getPassportNo());

      }

      }
      }catch (NamingException ne) {System.out.println("NamingException in Passport");ne.printStackTrace(); }
      catch (FinderException fe) {System.out.println("FinderException in Passport");fe.printStackTrace(); }
      catch(Throwable e){ e.printStackTrace(); }
      return list;
      }


      output display:
      ------------------

      ------result.size()--------3
      candidatePassportLocal.getPassportNo()-->b
      candidatePassportLocal.getPassportNo()-->b
      candidatePassportLocal.getPassportNo()-->b


      here b is a value in the database table with field named:passport
      This b value is retrieve from the last record from the table passport column.

      Please help me why i am getting the wrong output:

      with regards
      nischal sharma