开发者

JPA XML Query File

开发者 https://www.devze.com 2023-01-20 13:59 出处:网络
I would 开发者_StackOverflow中文版like to include all named queries in a separate XML file and use it in persistence. How can I accomplish the same?

I would 开发者_StackOverflow中文版like to include all named queries in a separate XML file and use it in persistence. How can I accomplish the same?

I am using Toplink JPA in a JSF-Web application. Actually, I am not able to get the directory/file structure to use.

I tried to use <mapping-file> in persistence.xml and tried to place the query file in several locations. Every time I am getting exception.


You can either place to XML file queries that later will be executed by

 EntityManager.createQuey(query)

where query is provided by XML.

Or, the better way(!), use already existing possibility to declare JPA parts in mapping XML (example see define named query in orm.xml with jpa and hibernate). In the last case you can even use:

 EntityManager.createNamedQuery(queryName)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号