org.hibernate.hql.internal.ast.QuerySyntaxException Invalid path
<p>I devised category and subcategory form in jsf. When I select any category, subcategory related with this category are shown in dropdown. I have a issue how to write hql file. Category and Subcategory is depended on onetomany and vice versa. </p>

<p>Here is the subcategory dao below.</p>

<pre><code>public List getAllSubCategoriesSelectItemName(String name) {
    // TODO Auto-generated method stub
    Session session = HibernateUtil.getSessionFactory().openSession();

    try {

        List&lt;Category&gt; liste = session.createQuery("Select S.SubName from SubCategory S left join SC.category scc where scc.name='"+name+"'").list();
        return liste;


    } catch (Exception e) {
        e.printStackTrace();

    }finally {

        session.close();

    }
    return null;
}



    @Entity
    @Table(name="CATEGORY",schema="DEMO")
    public class Category implements Serializable{

    @Id
 @SequenceGenerator(name="catseq",sequenceName="seqCatSEQ",allocationSize=1)
    @GeneratedValue(generator="catseq",strategy=GenerationType.SEQUENCE)
    @Column(name="ID")
    private Integer id;

    @Column(name="NAME")
    private String name;

    @Column(name="CAT_DESC")
    private String catDesc;


    @OneToMany(cascade = { CascadeType.PERSIST },mappedBy="category")
    private Set&lt;SubCategory&gt; subcategories = new HashSet();

    public Category() {
        super();
        // TODO Auto-generated constructor stub
    }


    public Category(String name, String catDesc) {
        super();
        this.name = name;
        this.catDesc = catDesc;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCatDesc() {
        return catDesc;
    }

    public void setCatDesc(String catDesc) {
        this.catDesc = catDesc;
    }


    public Set&lt;SubCategory&gt; getSubcategories() {
        return subcategories;
    }


    public void setSubcategories(Set&lt;SubCategory&gt; subcategories) {
        this.subcategories = subcategories;
    }


}

package entities;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


@Entity
@Table(name="SUBCATEGORY",schema="DEMO")
public class SubCategory implements Serializable{

    @Id
    @SequenceGenerator(name="subcatseq",sequenceName="seqSubCatSEQ",allocationSize=1)
    @GeneratedValue(generator="subcatseq",strategy=GenerationType.SEQUENCE)
    @Column(name="ID")
    private Integer id;

    @Column(name="SUBNAME")
    private String SubName;

    @Column(name="SUBNAME_DESC")
    private String SubNameDes;

    @ManyToOne(cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    @JoinColumn(name = "CAT_ID")
    private Category category;

    @ManyToMany(cascade=CascadeType.PERSIST,mappedBy="subcategories")
    Set&lt;Product&gt; products = new HashSet&lt;Product&gt;();


    public SubCategory() {
        super();
        // TODO Auto-generated constructor stub
    }

    public SubCategory(String subName, String subNameDes) {
        super();
        SubName = subName;
        SubNameDes = subNameDes;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getSubName() {
        return SubName;
    }

    public void setSubName(String subName) {
        SubName = subName;
    }

    public String getSubNameDes() {
        return SubNameDes;
    }

    public void setSubNameDes(String subNameDes) {
        SubNameDes = subNameDes;
    }


    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }



}
</code></pre>