蓬头钓客 2015-08-01 02:50 采纳率: 0%
浏览 1561

ssh2 org.hibernate.MappingException

org.hibernate.MappingException: Unknown entity: FROM Role

 <?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>

        <!-- 数据库连接信息 -->
        <property name="dialect">
            org.hibernate.dialect.MySQL5InnoDBDialect
        </property>
        <!-- <property name="connection.url">jdbc:mysql://localhost/oa</property> 
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="connection.username">root</property> <property name="connection.password">leibin</property> 
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property 
            name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
            <property name="connection.url">jdbc:oracle:thin:@localhost:1521:SXT</property> 
            <property name="connection.username">scott</property> <property name="connection.password">tiger</property> 
            <property name="dialect">org.hibernate.dialect.OracleDialect</property> -->


        <!-- 2.其他配置 -->

        <property name="hbm2ddl.auto">update</property>

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


        <!-- 3.导入映射文件 -->
        <mapping resource="com/leibin/oa/domain/User.hbm.xml" />
        <mapping resource="com/leibin/oa/domain/Role.hbm.xml" />

    </session-factory>

</hibernate-configuration>
 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:component-scan base-package="com.leibin.oa"></context:component-scan>

    <context:property-placeholder location="classpath:jdbc.properties"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
        <property name="dataSource">
            <bean class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <property name="jdbcUrl" value="${jdbcUrl}"></property>
                <property name="driverClass" value="${driverClass}"></property>
                <property name="user" value="${user}"></property>
                <property name="password" value="${password}"></property>

                <!-- 其他配置 -->
                <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
                <property name="initialPoolSize" value="3"></property>
                <!--连接池中保留的最小连接数。Default: 3 -->
                <property name="minPoolSize" value="3"></property>
                <!--连接池中保留的最大连接数。Default: 15 -->
                <property name="maxPoolSize" value="5"></property>
                <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
                <property name="acquireIncrement" value="3"></property>
                <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->
                <property name="maxStatements" value="8"></property>
                <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 -->
                <property name="maxStatementsPerConnection" value="5"></property>
                <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
                <property name="maxIdleTime" value="1800"></property>
            </bean>
        </property>
    </bean>

    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <tx:annotation-driven transaction-manager="txManager"/>

</beans>

 package com.leibin.oa.domain;

public class Role {

    private Long id;
    private String name;
    private String description;

    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }

}

 <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.leibin.oa.domain">
    <class name="Role" table="oa_role">
        <id name="id">
            <generator class="native"></generator>
        </id>

        <property name="name"></property>
        <property name="description"></property>
    </class>

</hibernate-mapping>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)