相关疑难解决方法(0)

Hibernate映射包

我正在使用Hibernate Annotations.

在我的所有模型类中,我都这样注释:

@Entity
@Table
public class SomeModelClass {
//
}
Run Code Online (Sandbox Code Playgroud)

我的hibernate.cfg.xml是

<hibernate-configuration>
   <session-factory>
      <!-- some properties -->

      <mapping package="com.fooPackage" />
      <mapping class="com.fooPackage.SomeModelClass" />
    </session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)

对于我添加到com.fooPackage的每个类,我必须在hibernate.cfg.xml中添加一行,如下所示:

<mapping class="com.fooPackage.AnotherModelClass" />
Run Code Online (Sandbox Code Playgroud)

有没有办法我可以添加新的模型类,但不需要将此行添加到hibernate.cfg.xml?

java hibernate hibernate-annotations

39
推荐指数
3
解决办法
5万
查看次数

标签 统计

hibernate ×1

hibernate-annotations ×1

java ×1