Hi,
Apparently what I thought was a clear response, you did not find so.  I'll
try again.


Here's your code annotated.

private ProjectInfoHome projectinfohome;
 private ProjectInfo projectinfo;

 public ProjectInfoJB getProjectInfoJB(int projectid) throws
RemoteException, ICantFindItException {

    //to avoid spurious results from reuse of session bean instances,
always initialize your variables.
    projectinfo = null;

    try{
     projectinfo = projectinfohome.findByPrimaryKey(new
ProjectInfoPK(projectid));
    }
    catch(FinderException fe){
//If you get here, you know for sure the bean you are looking for doesn't
exist. 
// Don't just ignore it, figure out what you want to do and do it;
        throw new ICantFindItException();
    }
//with the initialization above, if the find failed, and you ignore the
exception, you will at least get a null pointer exception, better than the
wrong answer.
    return projectinfo.getProjectInfoJB(); -->get value object

  }


   public ProjectInfoJB getProjectInfoJB() throws RemoteException{

//where is projectinfojb coming from? normally you would create a new
object to hand out.  
//If you already handed this one out to someone, and modify it when the
session bean is reused, 
//the guy who got the reference first is going to get the new values...not
what you want.

    
      ProjectInfoJB projectinfojb = new ProjectInfoJB();  //get a new one
to return.

      projectinfojb.setAgreementdate(this.agreementdate);
      projectinfojb.setClient(this.client);
      projectinfojb.setCommencementdate(this.commencementdate);
      projectinfojb.setComments(this.comments);
      projectinfojb.setCompanyid(this.companyid);
      projectinfojb.setCompletedate(this.completedate);
      projectinfojb.setContractor(this.contractor);
      projectinfojb.setContractorperiod(this.contractorperiod);
      projectinfojb.setContractvalue(this.contractvalue);
      projectinfojb.setCountry(this.country);
      projectinfojb.setInchargedp(this.inchargedp);
      projectinfojb.setInchargeperson(this.inchargeperson);
      projectinfojb.setOthersconsultant(this.othersconsultant);
      projectinfojb.setProjectid(this.projectid);
      projectinfojb.setProjectname(this.projectname);
      projectinfojb.setProjectno(this.projectno);
      projectinfojb.setProjecttype(this.projecttype);
      projectinfojb.setServicescope(this.servicescope);
      projectinfojb.setStatus(this.status);

    return projectinfojb;
  
}


On 2001.05.10 21:46:48 -0400 Russell wrote:
> Hi David ,
>   
>   If i ignoring the exception , didn't the method will throw null
> pointer exception to client.
>   I have do a testing and found that because my session is stateless
> bean , instance variable is not specific for all client.
>   If i change the session to stateful , the method will throw null
> pointer exception.
> 
>   Am I correct to said that ?
> 
>  Thanks 
>   
><snip>


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to