利用hibernate tools生成mssql的实体类

参考:http://blog.csdn.net/anglebeat/article/details/46373497

1、先到官网现在hibernate tools组件,目前已经加到jboss中,下载时注意自己所用的eclipse版本,选择对应的jboss版本(jdk版本和eclipse版本)

具体如何安装自己百度

2、利用hibernate tools创建配置cfg文件,生成后的xml文件如下(例子是连接mssql2012的,注意driver_class和url是否正确)

<?xml version="1.0" encoding="utf-8"?>
<!--利用本地dtd<!DOCTYPE hibernate-configuration SYSTEM        "file:///E:/Download/Program/hibernate-configuration-3.0.dtd">-->


<!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="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.password">Passw0rd</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1:1433;DatabaseName=YHDB;</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.default_schema">dbo</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    </session-factory>
</hibernate-configuration>

注意:生成cfg文件时,需要验证dtd文件,如果网络访问不到
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
中的url,会一直显示解析xml失败。(也可以下载dtd,把PUBLIC(外部)改成SYSTEM(内部),指定dtd物理路径)
3、生成console configuration文件
4、生成reveng.xml文件
5、切到hibernate configuration视图,执行hibernate code generation configuration,配置一下就可批量生成实体类和映射文件
注:步骤3、4、5请参考帖子:http://blog.csdn.net/gaojinshan/article/details/39502509







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值