node to traverse cannot be null exception in hibernate
<p>I have been trying CRUD operation using spring and hibernate but get following exception.</p>

<pre><code>java.lang.IllegalArgumentException: node to traverse cannot be null!
    at org.hibernate.hql.internal.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:64) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:300) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:126) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:88) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
    at com.kimaya.webpanel.dao.MenuDAOImpl.getMenu(MenuDAOImpl.java:51) ~[MenuDAOImpl.class:na]
    at com.kimaya.webpanel.dao.MenuDAOImpl.removeMenu(MenuDAOImpl.java:87) ~[MenuDAOImpl.class:na]
    at com.kimaya.webpanel.service.MenuServiceImpl.removeMenu(MenuServiceImpl.java:48) ~[MenuServiceImpl.class:na]
    at com.kimaya.webpanel.web.controller.MenuController.removeMenu(MenuController.java:70) ~[MenuController.class:na]
</code></pre>

<p>Here is my MenuDAOImpl class</p>

<pre><code>package com.kimaya.webpanel.dao;


import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.kimaya.webpanel.model.Menu;
import com.kimaya.webpanel.model.User;

@Repository("menuDAO")
public class MenuDAOImpl implements MenuDAO {

    protected static Logger logger = LoggerFactory.getLogger(MenuDAO.class);

    @Autowired
    protected SessionFactory sessionFactory;


    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    public void addMenu(Menu menu) {
        Session session = sessionFactory.openSession();
        String parentmenu = menu.getMenuname();
        String menuname[] = menu.getMenuname().split(" ");
        int parentid = Integer.parseInt(menuname[0]);
        //Query q = session.createQuery("from "+Menu.class.getName()+" where menuname="+menu.getMenuname());
        menu.setParentid(parentid);
        String mname[] = parentmenu.split(",");
        menu.setMenuname(mname[1]);
        session.save(menu);
    }

    public Menu getMenu(Integer menuid) {
        Session session=null;
        Transaction transaction = null;
        List&lt;Menu&gt; menus = null;
        try{
            session = sessionFactory.openSession();
            transaction = session.beginTransaction();
            Query q = session.createQuery("from" + Menu.class.getName() + "where menuid="+menuid);
             menus = q.list();
             return menus.get(0);
        }
        catch(HibernateException e) {
            transaction.rollback();
        } finally {
            session.close();
        }
        return menus.get(0);

    }

    public void updateMenu(Menu menu) {
        Session session = sessionFactory.openSession();
        session.update(menu);
    }



    public List&lt;Menu&gt; menuList(){
        Session session = sessionFactory.openSession();
        //Query q = session.createQuery("select g from " + Menu.class.getName() + " g");
        //List&lt;Menu&gt; menulist = q.list();

        List&lt;Menu&gt; menulist = session.createQuery("from "+Menu.class.getName()).list();

        return menulist;
    }

    public void removeMenu(Integer menuid) {
        Session session = null;
        Transaction transaction = null;
        try {
            session = sessionFactory.openSession();
            transaction = session.beginTransaction();
            session.delete(this.getMenu(menuid));
            transaction.commit();
        } catch(HibernateException e) {
            transaction.rollback();
        } finally {
            session.close();
        }   
    }

}
</code></pre>

<p>I can not able to understand why this exception comes and how to resolve it.
Please help me.</p>

<p>Thanks in advance !!</p>