-
December 30th, 2018, 01:02 PM
#1
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;
}
Last edited by Arjay; December 30th, 2018 at 01:54 PM.
Reason: Fixed up closing code tag
-
December 30th, 2018, 02:02 PM
#2
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?
-
December 30th, 2018, 02:38 PM
#3
Re: Error doing a deleteorder method - java ee
Can you copy the full text of the error message and paste it here?
Norm
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|