0

我目前正在开发一个使用 hibernate.cfg.xml 的 Web 项目。现在我计划将所有实体模型类移动到一个单独的 jar 中,然后从外部 jar 中引用实体。我也没有在任何地方使用实体管理器。我正在使用 SessionFactory 所以只包含 hibernate.cfg.xml 文件。

下面的 Hibernate.cfg.file 已经放在 WEB-INF->classes 文件夹中

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">org.sqlite.JDBC</property>

        <property name="connection.url">jdbc:sqlite:C:\workspace\gsepHelpdeskDB.sqlite</property>
        <property name="connection.username"></property>
        <property name="connection.password"/>


            <property name="hibernate.connection.provider_class">
                        org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.min_size">1</property>
        <property name="hibernate.c3p0.max_size">50</property>
        <property name="hibernate.c3p0.timeout">120</property>
        <property name="hibernate.c3p0.max_statements">10</property>

        <!-- SQL dialect -->
        <property name="dialect">com.enigmabridge.hibernate.dialect.SQLiteDialect</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <!-- <property name="hbm2ddl.auto">create</property> -->

        <!-- Do not Drop, only update the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>

            <!-- <mapping resource="org.hibernateDemo.dto.UserDetails.hbm.xml"/> -->      
    <mapping class="com.daimler.gsep.Tool"/>
    <mapping class="com.daimler.gsep.RequestorInfo"/>



    </session-factory>

</hibernate-configuration>

hibernate 配置文件的映射标签中提到的实体类实际上是放在一个名为 projectAutomationPOJOs.jar 的 jar 中。我已将 jar 放在 lib 文件夹中。当我运行应用程序时,我会收到“工具未映射”之类的错误。

4

0 回答 0