Is there a way to externalize HQL named queries to an external file. I have too many named queries and using @NamedQueries and @NamedQuery at the head of my entities classes is hurting.
Is there a way to externalize to several files?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can put the queries into
package-info.javaclass, in, say, root package of your domain objects. However, you must use Hibernate’s own@NamedQueriesand@NamedQueryannotations, rather than those fromjavax.persistence.Example
package-info.javafile:Then, you have to add the package to your
AnnotationConfiguration. I use Spring, so there it’s a matter of settingannonatedPackagesproperty:You can also put type and filter definitions in the same file as well.