惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 笑笑江南

sss IBATIS 延迟加载 iBATIS一对多/多对多N+1问题解决方案 - 笑笑江南 - 博客园 [转]office outlook 2007 如何设置开机自动启动 代码整洁之道 类关系 eclipse 快捷键 9-15 企业数据更新 mysql 常用函数 配置eclipse下tomcat启动参数【转】 安装svneclipse .net 开发相关工具(包)的作用 basicform 与 store gridpanel中拖拽排序 struts2 file 标签产生的一个问题 使用 ajax 提交数据 applyTo ,render, contentel,el,applytomarkup 的区别 呕吐呕吐 tabpanel 添加 tab
利用myeclipse生成Hibernate Mapping文件【转】
笑笑江南 · 2009-08-24 · via 博客园 - 笑笑江南

利用myeclipse生成Hibernate Mapping文件
关键字: hibernate
在hibernate中,每个数据表对应的其实是一个实体类,每个实体类有一个对应的hbm.xml配置文件和你匹配,myeclipse中其实有个MyEclipse Database Explorer视图,它提供了myeclipse与数据库直接连接的内置窗口,并且通过此窗口可以生成hibernate的mapping文件。

1.在项目上点击右键选择MyEclipse选项,为应用增加Hibernate特性.

2.在出现的配置窗口中,选中“Add Hibernate 2.1 libraries to project?”,然后设定存放Hibernate库文件的目录为: /WEB-INF/lib 目录,默认会选择创建一个新的Hibernate配置文件hibernate.cfg.xml。

3.点击下一步,进入Hibernate数据库连接配置界面,在Connection Profile选项中直接选择在MyEclipse Database Explorer中配置的vipdata选项,然后就会自动生成其他的配置,可以选择“Copy JDBC Driver and add to classpath”,这样就会将JDBC驱动拷贝到WEB-INF/lib目录中。:

4.点击下一步,来创建Hibernate的SessionFactory类,这是一个简单的集中管理Hibernate会话的工厂类,填写类的全名称。

5.点击完成,然后MyEclipse就会将Hibernate相关的jar包拷贝到lib目录下,同时会生成Hibernate的配置文件:hibernate.cfg.xml,和SessionFactory类。

现在要利用MyEclipse Database Explorer视图中的工具来生成Hibernate的映射文件。切换到MyEclipse Database Explorer视图,在表vipdata上点击右键,选择Create Hibernate Mapping.

6.配置生成的持久化类和映射文件。

7.点击Browse,选择生成的类和映射文件的包:com.xxx

8.ID Generator算法选项,选择native。(还有很多其他的选项可选,根据应用的需要具体选择,好像hibernate映射的表必须有主健,否则无法利用hibernate技术)。

9.点击完成,这样会生成持久化类Vipdata和它的父类AbstractVipdata(生成父类,有利于日后应用的扩展,工具会自动生成详细的equals方法和hashCode方法)以及映射文件xxx.hbm.xml。同时会修改Hibernate的配置文件hibernate.cfg.xml,会增加一行.