Error doing a deleteorder method - java ee
I need to do a deleteorder method, my idea is to compare all the books that the shop has with the books that are in the order, and then increase the quantity in the stock and remove the order.
Code:
public void deleteOrder(Customer customer, long idOrder){
for (int i=0; i<=customer.getOrders().size(); i++){
if(customer.getOrders().get(i).size()==idOrder){
for(int j=0; j<=SessionMB.getBooks().size(); j++){ #here is the error
#### in sessionmb.java
public List<Books> getBooks(){
return listBooks.allBooks();
#### in listbooks.java
public List<Books> allBooks(){
TypedQuery<Books> query=em.createQuery("SELECT m FROM books m", books.class);
return query.getResultList();
#### in other .java
public void incStock(int quantity) {
stock += quantity;
}
Re: Error doing a deleteorder method - java ee
A couple things:
1) the for loop should use i< rather than i<= (i<= will cause an out of bounds index error)
2) has SessionMB been initialized?
Re: Error doing a deleteorder method - java ee
Quote:
#here is the error
Can you copy the full text of the error message and paste it here?