문제

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top