休眠中的 hbm 文件

发布于 2024-09-28 14:17:31 字数 422 浏览 2 评论 0原文

我正在对 Hibernate 应用程序进行一些更新。其中使用了Struts和Spring。 我们在配置文件(.cfg 文件)中输入 .hbm 文件。但是当将 spring 与 hibernate 应用程序一起使用时,我们会在 application context.xml 中进行条目。 但我在整个应用程序中找不到配置条目。 是否有任何其他类我们配置了 .hbm 文件,

我正在执行此处定义的任务: 链接文字 我正在更新一个应用程序。其中存在许多 hbm 文件。我还创建了一个新的 .hbm.xml 文件。现在我想配置这个新的 .hbm 文件。但在整个应用程序中,我找不到配置所有 .hbm 文件的配置文件。

i am working on some updation in Hibernate application. in which Struts and Spring used.
we do entries of .hbm file in configration file(.cfg file). but when using spring with hibernate app we do entries in application context.xml.
but i can not find configration entries in entire application.
Is there any other class where we configured the .hbm files

i am doing a task define here: link text
i am working on updation a application. in this many hbm files are exist. i have also create a new .hbm.xml files. now i want to configured this new .hbm file. but in entire application i can not find the configration file where all .hbm files configured.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

近箐 2024-10-05 14:17:31

Hibernate 映射文件可以通过以下方式声明:

在创建 Configuration 时以编程方式

声明例如:

Configuration cfg = new Configuration()
    .addResource("Item.hbm.xml")
    .addResource("Bid.hbm.xml");

在 Hibernate XML 配置文件中

例如:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory name="">

    <!-- Database connection settings -->
    <property name="connection.driver_class">${jdbc.driver}</property>
    <property name="connection.url">${jdbc.url}</property>
    <property name="connection.username">${jdbc.user}</property>
    <property name="connection.password">${jdbc.password}</property>

    ...

    <mapping resource="com/acme/Foo.hbm.xml"/>
    <mapping resource="com/acme/Bar.hbm.xml"/>
    ...
  </session-factory>
</hibernate-configuration>

在 Spring XML 应用程序上下文定义中

例如:

<beans>

  <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>
  </bean>

  <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingResources">
      <list>
        <value>product.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.HSQLDialect
      </value>
    </property>
  </bean>

</beans>

由于您正在使用 Spring,因此您'我们很可能会使用上述方法。

资源


由于拥有来源,恐怕您在不显示更多内容的情况下不会获得任何更具体的帮助(这可能是不可能的)。如果需要,请进行文本搜索,内容无法隐藏。

Hibernate mapping files are either declared:

Programmatically when creating a Configuration

For example:

Configuration cfg = new Configuration()
    .addResource("Item.hbm.xml")
    .addResource("Bid.hbm.xml");

In an Hibernate XML configuration file

For example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory name="">

    <!-- Database connection settings -->
    <property name="connection.driver_class">${jdbc.driver}</property>
    <property name="connection.url">${jdbc.url}</property>
    <property name="connection.username">${jdbc.user}</property>
    <property name="connection.password">${jdbc.password}</property>

    ...

    <mapping resource="com/acme/Foo.hbm.xml"/>
    <mapping resource="com/acme/Bar.hbm.xml"/>
    ...
  </session-factory>
</hibernate-configuration>

In a Spring XML application context definition

For example:

<beans>

  <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>
  </bean>

  <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingResources">
      <list>
        <value>product.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.HSQLDialect
      </value>
    </property>
  </bean>

</beans>

Since you're using Spring, you're very likely using the above approach.

Resources


And since you have the sources, I'm afraid you won't get any more specific help without showing more stuff (which might not be possible). Do a text search if required, things can't be hidden.

放手` 2024-10-05 14:17:31
    @Autowired
    private ResourceLoader rl;

    public Resource[] loadResources() {
      Resource[] resources = null;
    try {
        resources = ResourcePatternUtils.getResourcePatternResolver(rl)
                .getResources("classpath:/hibernate/*.hbm.xml");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return resources;

}
    @Autowired
    private ResourceLoader rl;

    public Resource[] loadResources() {
      Resource[] resources = null;
    try {
        resources = ResourcePatternUtils.getResourcePatternResolver(rl)
                .getResources("classpath:/hibernate/*.hbm.xml");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return resources;

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文