| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2272 人关注过本帖, 1 人收藏
标题:hibernate操作数据库时出现问题,请各路大神帮
只看楼主 加入收藏
zcb炒冰
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-11-9
收藏(1)
 问题点数:0 回复次数:1 
hibernate操作数据库时出现问题,请各路大神帮
tomcat可以正常启动,但是项目没有达到预期效果
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting propert
y 'source' to 'org.eclipse.jst.jee.server:hibernate' did not find a matching pro
perty.


下面是hibernate。cfg.xml文件
程序代码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC 
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
  "http://hibernate. 定义数据库连接驱动 -->
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <!-- 定义数据库服务器地址 --> 
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/zcbtext</property> 
    <!-- 数据库用户名 -->
    <property name="hibernate.connection.username">root</property> 
    <!-- 数据库用户对应的密码 --> 
    <property name="hibernate.connection.password">442044</property> 
    <!-- 数据库对应的方言 --> 
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
    <!-- 在操作数据库时是否打印SQL语句 --> 
    <property name="hibernate.show_sql">true</property> 
    <!-- 打开 hbm2ddl.auto 选项将自动生成数据库模式(schema)- 直接加入数据库中 --> 
    <property name="hbm2ddl.auto">update</property>
    <!-- 配置ORM映射文件 --> 
    <mapping resource="Person.hbm.xml"></mapping> 
  </session-factory> 

 </hibernate-configuration>


下面是Person.hbm.xml文件
程序代码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate. class元素定义持久化类的具体包路径、关联的数据库及表名称 -->
<hibernate-mapping>
    <class name="com.henu.domain.Person" table="person">
        <!-- id元素定义表的主键对应持久化类中的属性名称、数据类型 -->
        <id name="id" column="id" type="int">
            <!-- generator定义表的主键生成方式,这里采用native方式 -->
            <generator class="increment"></generator>
        </id>
        <!-- property元素定义持久化类的其它属性与表中列名之间的对照关系及数据类型等 -->
        <property name="name" column="name" type="string"></property>
        <property name="age" column="age" type="int"></property>
        <property name="major" column="major" type="string"></property>
    </class>
</hibernate-mapping>

Mysql数据库中的数据库名是zcbtext,表名是person,属性有id,name,age,major
请大神帮忙!小弟这里谢谢!

[ 本帖最后由 zcb炒冰 于 2013-11-9 12:05 编辑 ]
搜索更多相关主题的帖子: hibernate property matching version PUBLIC 
2013-11-09 12:02
不玩虚的
Rank: 9Rank: 9Rank: 9
来 自:四川
等 级:贵宾
威 望:10
帖 子:331
专家分:1301
注 册:2012-12-9
收藏
得分:0 
上hibernate官网有例子

同学习......同进步....你帮我......我帮你.....上善若水.....
2013-11-17 08:50
快速回复:hibernate操作数据库时出现问题,请各路大神帮
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021140 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved