java - NullPointerError on saveOrUpdate Hibernate -


i trying update object in function:

public void pricelot(long lotid) throws exception {     lot lot = this.getlotbyid(lotid);     list list = bookservice.getbooksbylotnumber(lotid);     book book = new book();     productavailability pa = null;     float retail = 0;     for(int = 0; < list.size(); i++) {         book = (book) list.get(i);         retail += book.getprice();     }     if(retail == 0) {         retail = 1;     }     float ratio = lot.getamount() / retail;     for(int = 0; < list.size(); i++) {         book = (book) list.get(i);         pa = book.getproductavailability();         pa.setcost(pa.getretail() * ratio);         productavailabilityservice.saveorupdateproductavailability(pa);     }     lot.setpriced(true);     this.saveorupdate(lot); } 

it runs line

productavailabilityservice.saveorupdateproductavailability(pa); 

and here, dead-ends , returns nullpointerexception. don't know why it's doing this--nothing should null. here stack trace:

java.lang.nullpointerexception     com.samwellers.service.lotservice.pricelot(lotservice.java:69)     com.samwellers.control.admin.lotadmin.pricelotcontroller.handlerequest(pricelotcontroller.java:29)     org.springframework.web.servlet.mvc.simplecontrollerhandleradapter.handle(simplecontrollerhandleradapter.java:45)     org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:806)     org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:736)     org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:396)     org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:360)     javax.servlet.http.httpservlet.service(httpservlet.java:643)     javax.servlet.http.httpservlet.service(httpservlet.java:723) 

there should not null being passed saveorupdateproductavailability -- , function should have no problems. works fine in plenty of other places.

you should probable give information. far can see, both pa variable productavailibilityservice null @ time exception invoked.

have debugged , checked pa set correctly, , service available?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -