eclipse 中 使用Hibernate Tools 3.4 从数据库方向生成 hibernate 配置文件
2012-05-10 11:52
686 查看
eclispe 不想Myeclipse里面有自带的反响 从数据库里面生成 配置文件和类。但eclipse很友好,可能容纳各种插件,想装什么,就装什么,不走寻常路。首先到hibernate 的老窝去下载Hibernate Tools 插件,网站为:http://download.jboss.org/jbosstools/updates/development/indigo/,
在eclipse里面,windiow --->preferneces-->install ,输入,会跑出来一堆控件,选择Hibernate Tools 3.4即可(该网站是jboss 所有控件),安装,重启eclipse 。
如果你工程的五文件是采取SSH架构,而且,你的数据数配置,又放在该死的APPlication 上,很不幸的,你要重新生成一份hibernate配置文件,包括数据库URL ,方言,JDBC,用户名,密码等配置。
本文的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="ddc">
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@ip:database</property>
<!--指定连接数据库的用户名-->
<property name="connection.username">POSTMOBILE</property>
<property name="connection.password">POSTMOBILE</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
</session-factory>
</hibernate-configuration>
由此配置文件,接下来,当然是 反响生成文件了,hibernate,像Myeclipse那样,直接生成,它是先生成,反响配置文件。装了Hibernate Tools 3.4,后,在eclipse new 菜单里
接下来,根据提示,导入刚才的配置文件,然后选择你要的生成的表即可;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-schema="POSTMOBILE" match-name="TB_MAILINFO"/>
<table-filter match-schema="POSTMOBILE" match-name="TB_TRACE"/>
</hibernate-reverse-engineering>
生成的反响文件,
最后一步,就是根据方向配置文件,编译一下,生成你所需要的,类文件,和对该类hibernate配置文件,run-->hibernate code generatin.
Hibernate tools
http://www.hibernate.org/subprojects/tools.html
Hibernate Tools is a database reverse engineering tool that can generate domain model classes and Hibernate mapping files, annotated EJB3 entity beans, HTML documentation or even an entire JBoss Seam application in seconds!
> how to install hibernate tools
Help-Software
Updates,打开Available
Software选项卡,然后单击Add
Sites 分别输入JBoos的工具和Hibernate工具在线安装地址,然后选择安装Hibernate
ToolsJboos 和Tools
Development Release
http://download.jboss.org/jbosstools/updates/stable/
对于不同的eclipse版本以上链接不同,请参考eclipse的说明。
参考
http://developer.51cto.com/art/200906/128067.htm
> how to use hibernate tools
1. modify hibernate.cfg.xml
For oracle you should add following element to your .cfg.xml:
<hibernate-configuration>
<session-factory>
...
<property name="hibernate.default_schema">YOUR_SCHEMANAME_IN_UPPERCASE</property>
...
</session-factory>
</hibernate-configuration>
2. open perspective... -> Hibernate
3. create Hibernate Console Configuration:-
4. create reverse engine file:-
copy from below sample file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-name="YY_ICCODE" />
<table name="YY_ICCODE" class="Yy_iccode" schema="YB"></table>
</hibernate-reverse-engineering>
5. generate code:-
menu Run->Hibernate Code Generation...->Hibernate Code Generation Configuration...,
Exporters tab:
选择domain code和hibernate xml mapping
click "run"
sample reverse engine file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-name="YY_ICCODE" />
<table name="YY_ICCODE" class="Yy_iccode" schema="YB"></table>
</hibernate-reverse-engineering>
在eclipse里面,windiow --->preferneces-->install ,输入,会跑出来一堆控件,选择Hibernate Tools 3.4即可(该网站是jboss 所有控件),安装,重启eclipse 。
如果你工程的五文件是采取SSH架构,而且,你的数据数配置,又放在该死的APPlication 上,很不幸的,你要重新生成一份hibernate配置文件,包括数据库URL ,方言,JDBC,用户名,密码等配置。
本文的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="ddc">
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@ip:database</property>
<!--指定连接数据库的用户名-->
<property name="connection.username">POSTMOBILE</property>
<property name="connection.password">POSTMOBILE</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
</session-factory>
</hibernate-configuration>
由此配置文件,接下来,当然是 反响生成文件了,hibernate,像Myeclipse那样,直接生成,它是先生成,反响配置文件。装了Hibernate Tools 3.4,后,在eclipse new 菜单里
接下来,根据提示,导入刚才的配置文件,然后选择你要的生成的表即可;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-schema="POSTMOBILE" match-name="TB_MAILINFO"/>
<table-filter match-schema="POSTMOBILE" match-name="TB_TRACE"/>
</hibernate-reverse-engineering>
生成的反响文件,
最后一步,就是根据方向配置文件,编译一下,生成你所需要的,类文件,和对该类hibernate配置文件,run-->hibernate code generatin.
Hibernate tools
http://www.hibernate.org/subprojects/tools.html
Hibernate Tools is a database reverse engineering tool that can generate domain model classes and Hibernate mapping files, annotated EJB3 entity beans, HTML documentation or even an entire JBoss Seam application in seconds!
> how to install hibernate tools
Help-Software
Updates,打开Available
Software选项卡,然后单击Add
Sites 分别输入JBoos的工具和Hibernate工具在线安装地址,然后选择安装Hibernate
ToolsJboos 和Tools
Development Release
http://download.jboss.org/jbosstools/updates/stable/
对于不同的eclipse版本以上链接不同,请参考eclipse的说明。
参考
http://developer.51cto.com/art/200906/128067.htm
> how to use hibernate tools
1. modify hibernate.cfg.xml
For oracle you should add following element to your .cfg.xml:
<hibernate-configuration>
<session-factory>
...
<property name="hibernate.default_schema">YOUR_SCHEMANAME_IN_UPPERCASE</property>
...
</session-factory>
</hibernate-configuration>
2. open perspective... -> Hibernate
3. create Hibernate Console Configuration:-
4. create reverse engine file:-
copy from below sample file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-name="YY_ICCODE" />
<table name="YY_ICCODE" class="Yy_iccode" schema="YB"></table>
</hibernate-reverse-engineering>
5. generate code:-
menu Run->Hibernate Code Generation...->Hibernate Code Generation Configuration...,
Exporters tab:
选择domain code和hibernate xml mapping
click "run"
sample reverse engine file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-name="YY_ICCODE" />
<table name="YY_ICCODE" class="Yy_iccode" schema="YB"></table>
</hibernate-reverse-engineering>
相关文章推荐
- 使用myeclipse从数据库反射生成hibernate实体类和配置文件
- Eclipse使用xdoclet1.2.3 生成hibernate配置文件和映射文件
- eclipse下使用xdoclet生成hibernate的hbm映射文件
- eclipse用hibernate tools从数据库逆向生成Hibernate实体类
- eclipse 逆向工程生成hibernate实体类(注解或配置文件)
- 如何根据hibernate的实体类和实体类配置文件生成数据库的表
- 在eclipse中使用MyBatis Geneator自动生成出对应数据库的实体与映射文件
- Eclipse(LUNA4.4.2)配置hibernate(4.3.8)连接数据库并自动生成代码
- 添加JBoss插件中的hibernate tools后怎么创建hibernate配置文件和对数据库的表进行反转映射
- 在Spring中利用Hibernate的配置文件生成数据库表
- hibernate根据配置文件生成数据库表
- Spring整合Hibernate开发 - 使用事务管理器操作数据库 - 主配置文件
- 【JAVA】使用Eclipse依赖生成jar包时,避免最外层同时生成资源文件的配置。
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 使用Eclipse通过连接数据库生成实体类和映射文件
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- hibernate 在不使用xml配置的方式生成数据库表的方法
- hibernate根据配置文件生成数据库表
- hibernate通过配置文件生成数据库信息
- 根据hibernate配置文件生成数据库建表脚本