How do I create Named Queries in a Separate file
问题 I need to keep the all the named queries in a separate file. For example @javax.persistence.NamedQueries({ @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e")}) public class AllNamedQueries { } Now that much in itself causes an Error "Named queries can only be defined in Entity or MappedSuperClass class". How do I create Named Queries in a Separate file? By separate I mean files other than entity file. 回答1: You can use orm.xml that allows you to define JPA mappings in