Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Topics

Recent Status Updates

View All Updates

- - - - -

error non-static method in static context

java javaee

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 martarrrr


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 30 December 2018 - 09:00 AM

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.
I have an error doing a loop with all the books that there are in the shop, the error is "non-static method getBooks() cannot be referenced from a static context" and I dont know to solve it.
ublic void deleteOrder(Customer customer, long idOrder){
    for (int i=0; i<=customer.getOrders().size(); i++){
            for(int j=0; j<=SessionMB.getBooks().size(); j++){ #here is the error  

public List<Books> getBooks(){
    return listBooks.allBooks();

public List<Books> allBooks(){
    TypedQuery<Books> query=em.createQuery("SELECT m FROM books m", books.class);
    return query.getResultList();

public void incStock(int quantity) {
    stock += quantity;



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download