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 {
  ...
}
Please follow and like us:
Content Protection by DMCA.com