0 votes
in Hibernate by
What is named SQL query in Hibernate?

1 Answer

0 votes

Named Query is a type of query that is witten in simple bean (setter or getter) class. Any query is written in bean class for updating or working with databse.

You will see the following example to use Named Queries.

package developerhelpway.jpafunctions;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

 query="SELECT emp FROM Employee emp")
query="SELECT emp FROM Employee emp"),
 query="DELETE FROM Employee emp WHERE emp.id= ?1")

public class Employee {

  private int id;
  private String empName;
  private int empSalary;

  public int getId() {
    return id;

  public void setId(int id) {
    this.id = id;

  public String getEmpName() {
    return empName;

  public void setEmpName(String empName) {
    this.empName = empName;

  public int getEmpSalary() {
    return empSalary;

  public void setEmpSalary(int empSalary) {
    this.empSalary = empSalary;

For more: http://www.developerhelpway.com/framework/jpahibernate/jpa-named-queries.php


Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.