CodesJava

Easy learning with example program codes

JPA NamedQuery and NamedQueries annotations


The @NamedQuery and @NamedQueries annotations are used to define one or more JPQL queries. These queries will be associated with that particular entity.

@NamedQuery Example:

@Entity
@NamedQuery(name="Student.selectAllStudents", query="SELECT st FROM Students st") 
public class Students {
  ...
}

@NamedQueries Example:

@Entity
@NamedQueries({
   @NamedQuery(name="Student.selectAllStudents", query="SELECT st FROM Students st")
})
public class Students {
  ...
}
Posted in JPA   


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap