Spring 2.5 Hibernate 3.5 NamedQuery
-
27-09-2019 - |
문제
I do not use HibernateTemplate, but work with getCurrentSession() in my DAO.
I would like to know how to declare Hibernate named queries in a beans.xml file (I do not use hbm.xml).
And maybe Spring has alternative means to declare Hibernate named queries?
해결책
You can put named queries on the entity using annotations:
@NamedQueries({@NamedQuery(name="Entity.findAll", query="....")})
Also, if using JPA, there's orm.xml
, The XSD tells us that you can use:
<named-query name="Entity.findAll">
<query><![CDATA[SELECT e FROM Entity e]]</query>
</named-query>
제휴하지 않습니다 StackOverflow