Q:

@NamedQueries, create a new query in entity

I have generated an entity class from a database, and inside the @NamedQueries annoation  are created some usable "default" queries. So when I have to create my new sql query, I just write @NamedQuery and fill parameters with the name and new sql query. However, my question is that only place (@NamedQueries) where I should write all my queries and beside that, do I need to write some new method inside a class, specific to that query ?
@Entity
@Table(name = "category")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Category.findAll", query = "SELECT c FROM Category c"),
    @NamedQuery(name = "Category.findById", query = "SELECT c FROM Category c WHERE c.id = :id"),
    @NamedQuery(name = "Category.findByName", query = "SELECT c FROM Category c WHERE c.name = :name")})
public class Category implements Serializable {
...
}

A:

However, my question is that only place (@NamedQueries) where I should write all my queries and beside that, do I need to write some new method inside a class, specific to that query ?
Answer is no you need not write any new methods specific to this query or implement this. Query execution will be taken care by the underlying persistence provider.
And also this is the only way of creating namedqueries

