eclipse hibernate导出数据库实体类

时间:2023-03-08 15:45:32
eclipse hibernate导出数据库实体类

打开eclipse->help->Eclipse Marketplace->查找hibernate->安装如下插件

eclipse hibernate导出数据库实体类

只要安装其中一个,hibernate tool即可:

eclipse hibernate导出数据库实体类

安装完成后将hibernate添加到eclipse下方view区域:

window->show view->other->查找hibernate:

eclipse hibernate导出数据库实体类

确认后下方会多一个view区域:

eclipse hibernate导出数据库实体类

这是个hibernate配置管理区域,可以查看数据库内数据

当然第一次打开是什么都没有的,需要进行配置,右击view空白区域:add configuration

eclipse hibernate导出数据库实体类

注意第一个项目很好填写,后面还有两个,一个是数据库的配置文件,一般是properties文件,例如:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/exam?characterEncoding=utf8
jdbc.username=root
jdbc.password=

第二个文件完全可以自动生成:

eclipse hibernate导出数据库实体类

填写连接相关参数,其中的schema和catalog相关可查表:

供应商 Catalog支持 Schema支持
Oracle 不支持 Oracle User ID
MySQL 不支持 数据库名
MS SQL 数据库名 对象属主名,2005版开始有变
DB2 指定数据库对象时,Catalog部分省略 Catalog属主名
Sybase 数据库名 数据库属主名
Informix 不支持 不需要
PointBase 不支持 数据库名

eclipse hibernate导出数据库实体类

点击ok以后即可直接在底部view->Hibernate Configurations中查看数据库结构(如果查不到,表示连接不成功,重新配置)

window->perspective->customize perspective

eclipse hibernate导出数据库实体类

eclipse hibernate导出数据库实体类

eclipse hibernate导出数据库实体类

eclipse hibernate导出数据库实体类

eclipse hibernate导出数据库实体类

eclipse hibernate导出数据库实体类

Main中填写的导出的基本配置,导出的路径,导出到的包,然后exporters中是选择需要导出什么文件类型,除了POJO类(model),还可导出DAO等

效果:

eclipse hibernate导出数据库实体类