define named query in orm.xml with jpa and hibernate

后端 未结 4 2016
既然无缘
既然无缘 2020-12-05 10:55

I\'m trying to put my named queries in my orm.xml (put in META-INF with persistence.xml) but my orm.xml seems to be ignored by hibernate/jpa.

When I try to create m

4条回答
  •  Happy的楠姐
    2020-12-05 11:45

    "META-INF/orm.xml" is the default mapping file that will be looked upon by any JPA compliant entity manager.

    In fact, if your mapping file is "META-INF/orm.xml", you need not even define that in your persistence.xml.

    This is what the hibernate configuration manual says about this:

    The class element specifies a EJB3 compliant XML mapping file that you will map. The file has to be in the classpath. As per the EJB3 specification, Hibernate EntityManager will try to load the mapping file located in the jar file at META_INF/orm.xml. Of course any explicit mapping file will be loaded too. As a matter of fact, you can provides any XML file in the mapping file element ie. either hbm files or EJB3 deployment descriptor.

    Reference: Hibernate configuration

提交回复
热议问题