开发者

JPA XML Query File

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜