首先需安装eclipse的Jboss插件
1.导包

导入hibernate核心包与数据库连接驱动包。
2.新建hibernate.cfg.xml
右键工程-->New-->Other

next--->选择文件新建位置--->next

next

finish

下拉框选择Hibernate Code Generation Configurations



点击setup--->creat new

选择hibernate.reveng.xml所在位置--->next

如果之前的hibernate.cfg.xml配置项没有错误,且数据库连接打开,点击refresh会出现所需要的数据库,点击可查看该数据库的表。

选择需要的表,点击include,选择的表会出现在右侧的选择框,点击finish--->Run会在之前指定的位置的包中产生与表相对应的Bean类与***.hbm.xml文件

需要注意的是,这样生成可能会有一些小bug,需要自己根据出现的问题进行小小的调整。当然,也可能直接就是能使用的。
网友评论