休眠配置 - 会话工厂扫描? [英] Hibernate configuration - session factory scanning?

查看:140
本文介绍了休眠配置 - 会话工厂扫描?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有这个hibernate.cfg.xml文件。有没有办法告诉Hibernate只需扫描一个目录,而不必为每个类添加一个条目?

 <冬眠-结构> 
< session-factory>
< mapping class =com.abc.domain.model.A/>
< mapping class =com.abc.domain.model.B/>
< mapping class =com.abc.domain.model.C/>
< mapping class =com.abc.domain.model.D/>
< mapping class =com.abc.domain.model.E/>
< / session-factory>
< / hibernate-configuration>


解决方案

要获得发现机制,您需要使用Hibernate实现Java Persistence标准发现机制的EntityManager。否则,你需要列出你的课程。

We have this hibernate.cfg.xml file. Is there a way to tell Hibernate to just scan a directory instead of having to add an entry here for each class?

<hibernate-configuration>
   <session-factory>
      <mapping class="com.abc.domain.model.A" />
      <mapping class="com.abc.domain.model.B" />
      <mapping class="com.abc.domain.model.C" />
      <mapping class="com.abc.domain.model.D" />
      <mapping class="com.abc.domain.model.E" />
   </session-factory>
</hibernate-configuration>

解决方案

To get the discovery mechanism, you need to use Hibernate EntityManager which implements the Java Persistence standard discovery mechanism. Otherwise you need to list your classes.

这篇关于休眠配置 - 会话工厂扫描?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆