Hibernate 映像集合属性 org.hibernate.MappingException: 错误

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_26906345/article/details/79137688

Exception in thread “main” org.hibernate.MappingException: Unknown entity: test.Person

hibernate.cfg.xml下面的

<mapping resource="com/xxx/app/bean/News.hbm.xml"/>

更改为自己包的地址

<mapping resource="test/Person.hbm.xml"/>

完整的hibernate.cfg.xml

<?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>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">0308</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
        <property name="hibernate.format_sql">true</property>
        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.min_size">1</property>
        <property name="hibernate.c3p0.timeout">5000</property>
        <!-- 最大缓存多少个statement对象 -->
        <property name="hibernate.c3p0.max_statements">100</property>
        <property name="hibernate.c3p0.idle_test_period">3000</property>
        <property name="hibernate.c3p0.acquire_increment">2</property>
        <property name="hibernate.c3p0.validate">true</property>
        <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
        <property name="hbm2ddl.auto">update</property>
        <!-- JNDI tomcat -->
        <property name="connection.datasource">java:comp/env/jdbc/dstest</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <!-- 显示Hibernate持久化操作所生成的SQL -->
        <property name="show_sql">true</property>
        <!-- 将SQL脚本进行格式化后再输出 -->
        <property name="hibernate.format_sql">true</property>
        <mapping resource="test/Person.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

猜你喜欢

转载自blog.csdn.net/qq_26906345/article/details/79137688