[color=red][b]本文参考[/b][/color]: How To Generate Hibernate Mapping Files & Annotation With Hibernate Tools [url]http://www.mkyong.com/hibernate/how-to-generate-code-with-hibernate-tools/[/url]
eclipse利用Hibernate Tools生成Hibernate Mapping文件及PO类[url]http://kennylee26.iteye.com/blog/1039542[/url]
Trying to use code generation with eclipse 3.2 [url]https://forum.hibernate.org/viewtopic.php?f=6&t=964544[/url]
hibernate.cfg.xml: Hibernate的配置
hibernate.reveng.xml: 反转的配置
[color=red][b]注意:[/b][/color]
1. 在第一步选择Database Connection的时候, 是实现在Database Development窗口,成功建立一个到sql server 2008的连接,然后在这里才被选择的. 否则要New一个新的连接.
2.在[b][color=red]3. Hibernate Code Generation[/color][/b]的时候, 对Main选项卡一定要选择hibernate.reveng.xml文件.
3.在[b][color=red]3. Hibernate Code Generation[/color][/b]的时候, 在Export选项卡,要选择"User Java5 syntax","Generate EJB3 Annotation", 就会有java5的泛型和@Entity,@Table等注解.
4.在[b][color=red]3. Hibernate Code Generation[/color][/b]的时候,[b],配置hibernate.properties[/b]
hibernatetool.metadatadialect=org.hibernate.cfg.reveng.dialect.SQLServerMetaDataDialect
修改数据库语言:Dialect, 这里影响到pojo.id的注解,
MetaDataDialectFactory.createMetaDataDialect(); 这里没有正确从文件hibernate.properties获得dialect, 所以直接修改property=默认的dialect,
比如:String property ="org.hibernate.cfg.reveng.dialect.SQLServerMetaDataDialect"; SQLServerMetaDataDialect这个是在Hibernate-Tools.jar里面的.
5.重复类的解决办法:[url]http://www.cnblogs.com/linxi/archive/2009/07/12/1521950.html[/url]
eclipse利用Hibernate Tools生成Hibernate Mapping文件及PO类[url]http://kennylee26.iteye.com/blog/1039542[/url]
Trying to use code generation with eclipse 3.2 [url]https://forum.hibernate.org/viewtopic.php?f=6&t=964544[/url]
hibernate.cfg.xml: Hibernate的配置
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/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">sa</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=Test</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.search.autoregister_listeners">false</property>
</session-factory>
</hibernate-configuration>
hibernate.reveng.xml: 反转的配置
<?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-catalog="Test" match-schema="dbo" match-name=".*"/>
<table-filter match-catalog="Test" match-schema="dbo" match-name="sysdiagrams" exclude="true"/>
</hibernate-reverse-engineering>
[color=red][b]注意:[/b][/color]
1. 在第一步选择Database Connection的时候, 是实现在Database Development窗口,成功建立一个到sql server 2008的连接,然后在这里才被选择的. 否则要New一个新的连接.
2.在[b][color=red]3. Hibernate Code Generation[/color][/b]的时候, 对Main选项卡一定要选择hibernate.reveng.xml文件.
3.在[b][color=red]3. Hibernate Code Generation[/color][/b]的时候, 在Export选项卡,要选择"User Java5 syntax","Generate EJB3 Annotation", 就会有java5的泛型和@Entity,@Table等注解.
4.在[b][color=red]3. Hibernate Code Generation[/color][/b]的时候,[b],配置hibernate.properties[/b]
hibernatetool.metadatadialect=org.hibernate.cfg.reveng.dialect.SQLServerMetaDataDialect
修改数据库语言:Dialect, 这里影响到pojo.id的注解,
MetaDataDialectFactory.createMetaDataDialect(); 这里没有正确从文件hibernate.properties获得dialect, 所以直接修改property=默认的dialect,
比如:String property ="org.hibernate.cfg.reveng.dialect.SQLServerMetaDataDialect"; SQLServerMetaDataDialect这个是在Hibernate-Tools.jar里面的.
5.重复类的解决办法:[url]http://www.cnblogs.com/linxi/archive/2009/07/12/1521950.html[/url]