首页 > 其他分享 >Hibernate Tools生成Hibernate Mapping文件及PO类

Hibernate Tools生成Hibernate Mapping文件及PO类

时间:2023-06-04 14:32:00浏览次数:43  
标签:dialect Hibernate color Mapping url hibernate Tools red


[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的配置

<?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里面的.




标签:dialect,Hibernate,color,Mapping,url,hibernate,Tools,red
From: https://blog.51cto.com/u_3871599/6410626

相关文章

  • Flex+J2EE实例(cairngorm+blazeDS+hibernate+spring) part4 (完)
     Flex+J2EE实例(cairngorm+blazeDS+hibernate+spring)part4----addcairngorm1.添加在libs下添加Cairngorm.swc,此时,具备了cairngorm框架能力2.运用cairngorm框架2.1在flex_src下创建如下文件夹和文件   AdminVO.aspackagevo.AdminVO{ [Bindable] publicclassAdm......
  • Flex+J2EE实例(cairngorm+blazeDS+hibernate+spring) part3
    Flex+J2EE实例(cairngorm+blazeDS+hibernate+spring)part3                                   ----addspring &hibernate1.在WEB-INF\lib下添加spring、hibernate常用jar,包括mysql数据库的连接驱动  2.在mysql数据库中创建数据库......
  • Raspberry Pi command line tools vcgencmd All In One
    RaspberryPicommandlinetoolsvcgencmdAllInOnevcgencmd$vcgencmd-h$vcgencmd--helpUsage:vcgencmd[-t]commandSendacommandtotheVideoCoreandprinttheresult.-tTimehowlongthecommandtakestocomplete-h,--helpShowt......
  • [Debug] Debug and inspect event listeners with Devtools
    Youcanuse getEventListeners(button)directlyinsidechromedevtool,butnotinsideapplicationcode. Youcanuse monitorEvents(button,'keydown'),noweverytimeskeydownhappens,eventwillbeloggedintotheconsole.Use unmonitorEvents(but......
  • ModuleNotFoundError: No module named 'setuptools_rust'
    我在执行pip3installwebssh遇到以下的报错信息。报错信息Traceback(mostrecentcalllast):File“”,line1,inFile“/tmp/pip-build-my9sai1o/cryptography/setup.py”,line14,infromsetuptools_rustimportRustExtensionModuleNotFoundError:Nomodulenamed‘s......
  • devtools
    1、devtools简介SpringBoot提供了一组开发工具spring-boot-devtools可以提高开发者的工作效率,开发者可以将该模块包含在任何项目中,spring-boot-devtools最方便的地方莫过于热部署了。2、devtools实战2.1基本用法要想在项目中加入devtools模块,只需添加相关依赖即......
  • NS模拟器管理哪家强?就来Ns Emu Tools
    前言最近塞尔达传说:王国之泪​非常火爆,但是不少的小伙伴找到了ROM,但是在NS的模拟的寻找上遇到了问题。所以,我出手了。通过NsEmuTools这款软件,我们可以非常方便的安装和管理NS模拟器。什么是NS模拟器NS模拟器是一种可以模拟任天堂Switch游戏主机运行环境的软件。通过N......
  • hibernate session
       ......
  • Hibernate 映射关系
    orm框架是对jdbc的封装           每次都会生成新的数据表 ......
  • 【随手记录】Unable to create requested service [org.hibernate.engine.jdbc.env.sp
    链接数据库报错 Unabletocreaterequestedservice[org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]出现这个问题基本是数据库的方言dialect或者驱动driver_class有问题,可以确认下dialect或者driver_class的配置和自己要链接的库、库版本是否一致,比如:spring.jpa......