• Eclipse从数据库逆向生成Hibernate实体类和映射文件(Eclipse插件系列之HibernateTools)


    ♣下载安装Eclipse插件(HibernateTools)

    ♣Eclipse连接数据库(Mysql5.7)

    ♣新建hibernate.properties和hibernate.cfg.xml文件

    ♣打开Hibernate Configurations窗口

    创建hibernate.reveng.xml文件

    打开Customize Perspective窗口

    ♣最后:生成hibernate实体类和映射文件

    1.下载安装Eclipse插件(HibernateTools)

    去Hibernate的网站下载HibernateTools工具包。
    http://jaist.dl.sourceforge.net/sourceforge/jboss/HibernateTools-3.2.4.Beta1-R200810311334.zip 

    或者,可以点击这里下载

    下载后解压,得到features和plugins这两个文件夹,将features和plugins这两个文件夹其中的内容复制到eclipse目录下对应的features和plugins文件夹

    2.Eclipse连接数据库(Mysql5.7)

      使用eclipse自带的数据库管理器(Data Management),连接上数据库(Mysql5.7):

      点击Window -> Show View -> Other -> Data Sourse Explorer

      

    然后就弹出了如下图数据库管理的界面,在其上右键选择new:

    然后选择Mysql数据库,可以自定义命名:

    接着点击新建数据库驱动的按钮,加载本地的数据库驱动:

    选择比较高的版本

     到这里,eclipse就已经和Mysql5.7数据库连接上了

    3.新建hibernate.properties和hibernate.cfg.xml文件

      3.1新建hibernate.properties:

       

         右键项目名,new一个文件:

        

         

        3.2新建hibernate.cfg.xml:

        

         

         

         

        到此hibernate.properties和hibernate.cfg.xml文件就建立完成了。

    4.创建hibernate.reveng.xml

    到这里,hibernate.reveng.xml文件就新建完成了,点击finish后会弹出如下框:

     

    然后就可以关闭保存了。

    5.打开Hibernate Configurations窗口

       

      

      

      

      

     

    5.打开Customize Perspective窗口

     选择Customize Perspective选项,

     

     

    6.最后:生成hibernate实体类和映射文件

      之后工具栏就会出现一个新的按钮

     

     点击按钮的下拉标识,选中Hibernate Code Generation Configurations:

     然后就弹出如下的Generation Configurations框:

     

    效果如下图:

     最后的最后,欢迎光临xunCr.com

  • 相关阅读:
    墙奸有感
    关于ubuntu里的fcitx
    Ubuntu 9.10 ati HD 3470 显卡驱动 搞定
    XP与Ubuntu双系统的问题
    invalid conversion from ‘__pthread_t*’ to ‘pid_t’
    Julian Day
    m的n次幂的求法
    Sublime Text 2
    在虚拟机Virtualbox安装Win8消费者版
    记一个循环的错误
  • 原文地址:https://www.cnblogs.com/xiezhidong/p/6517065.html
Copyright © 2020-2023  润新知