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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.