1. 程式人生 > >Hibernate Tools for Eclipse的使用

Hibernate Tools for Eclipse的使用

Hibernate Tools的官方網站:http://hibernate.org/tools/
Step1安裝好Hibernate Tools,建立一個Dynamic web project,工程名為“test”。
Step2、以Mysql為示例,建立相應的測試資料庫及表,如下所示:
mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| customer       |
| login          |
+----------------+
2 rows in set (0.10 sec)
Step3、將MySql的Jdbc驅動庫(mysql-connector-java-5.0.8-bin.jar)拷貝至lib目錄。
Step4、利用Hibernate Tools生成Hibernate的cfg.xml。如下圖:

直接預設轉到下一步的配置介面,配置如下圖:

點選完成(Finish)後,它將生成如下xml的配置檔案(hibernate.cfg.xml):
<?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>
		<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
		<property name="hibernate.connection.password">
[email protected]
</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> </session-factory> </hibernate-configuration>
Step5、利用Hibernate Tools生成Hibernate的Console配置。如下圖:




點選完成(Finish)後,它將生成配置檔案,如下圖:

Step6、利用Hibernat Tools生成Hibernate的reveng.xml配置。如下圖:

直接預設轉到下一步的配置介面,配置如下圖:

點選完成(Finish)後,它將生成如下xml的配置檔案(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-name="customer" />
	<table-filter match-catalog="test" match-name="login" />
</hibernate-reverse-engineering>
Step7、最後一步了,生成對映檔案Java程式碼。如下圖:

點選執行(Run)後,它將生成如下對映檔案和Java程式碼檔案,如下圖:


參考:http://www.cnblogs.com/abllyboy/archive/2010/12/23/1914577.html

相關推薦

Hibernate入門第二課 Hibernate Tools for Eclipse Plugins安裝

tails center 問題 名稱 lips 心得 ane 軟件 ins Hibernate入門第二課 Hibernate Tools for Eclipse Plugins安裝 你們可以直接去,http://blog.csdn.net/wei_chong_chong/a

01-Hibernate Tools for Eclipse Plugins安裝

lan nload gin enter war 低版本 -h 鼠標 hiberna Hibernate Tools for Eclipse Plugins安裝 在線安裝有兩種方法 方法一:"Help > Install New Software Updates" 可

Hibernate學習——Hibernate Tools for Eclipse Plugins的下載與安裝

其他 重裝 需要 開發 打開 exp eat 第一步 lips Hibernate Tools是由JBoss推出的一個Eclipse綜合開發工具插件,可以簡化ORM框架Hibernate,以及JBoss Seam,EJB3等的開發工作。 1.下載Hibernate To

hibernate tools for eclipse plugins線上怎麼安裝

 1.啟動eclipse 2.選擇Help > Install New Software...> 3.新增如下地址:http://download.jboss.org/jbosstools/updates/stable/helios/ 4.選擇性安裝:hib

Hibernate Tools for Eclipse的使用

Hibernate Tools的官方網站:http://hibernate.org/tools/Step1、安裝好Hibernate Tools,建立一個Dynamic web project,工程名為“test”。Step2、以Mysql為示例,建立相應的測試資料庫及表,

Hibernate Tools for Eclipse外掛的安裝和使用【轉】

一直想拋棄Myeclipse,今天終於找到了不用它的理由, Eclipse的外掛這麼多,做什麼都可以。下面是如何用Hibernatetools進行Hibernate開發 安裝Hibernate外掛 方法一 啟動最新的Elcipse(eclipse-jee-ga

eclipse/sts安裝hibernate tools

hibernate tools是jboss中的一個便捷開發hibernate的一個工具,我們怎麼在eclipse或者sts中安裝它呢? (1)開啟eclipse,   help->install new software->add->名字輸入hibernat

關於eclipse hibernate tools外掛安裝問題

關於hibernate的下載安裝見下面連結https://blog.csdn.net/coderbruis/article/details/78267887我照著文章裡的建立生成hibernate.cfg.xml配置檔案時報錯The selected wizard could

Eclipse安裝Hibernate tools外掛自動生成程式碼

hibernate外掛安裝方法: http://download.jboss.org/jbosside/updates/stable 點選eclipse的help選單裡的“Install New Software”點選“Add”,輸入下面的內容,一路“NEXT”即可

How To Install Hibernate / JBoss Tools In Eclipse IDE

Hibernate Tools is a handy tool for Java’s developers to generate tedious hibernate related stuffs like mapping files and annotation cod

eclipse+hibernate tools逆向生成實體類不成功的解決方法

今天根據網上的教程試了下eclipse逆向生成實體類和.hbm.xml檔案,但是沒有成功,一開始是因為版本太高,為5.1版,後來改成了4.3版,但還是沒成功。經過自己的多次測試,發現了以下問題 在生成

eclipse離線安裝hibernate tools外掛

在eclipse根目錄下建立myplugins和links; 然後再在myplugins下建立hibernate_tools資料夾; 解壓提取下載jboss包的features和plugins兩個資料夾到hibernate_tools下,見下圖;

如何在eclipse中安裝Hibernate Tools

Generating.hbm.cfgfiles or creating annotated files to map your classes is always a bit boring and it involves writing a lot of boilerplate code. In Ec

eclipse怎樣線上安裝hibernate tools外掛並使用

不知不覺,小Alan已經將近3個月沒有上班了,最近在複習一些知識,隨時準備回到程式碼世界的戰場,今天覆習到了Hibernate,記錄一下一點點小知識,那就是eclipse下hibernate Tools的線上安裝,離線安裝的話速度應該會快那麼一些,但是個人感覺沒有線上安裝

官網下載完全匹配自己Eclipse版本的Hibernate Tools

1、進入hibernate ORM官網,可以先把hibernate下載過來,後來要用到。 2、然後選擇tools標籤——看到第一段話,之中有一句含有一個JBoss Tools的超連結,連結過去 3、進入jboss Tools的網頁後,選擇下載標

hibernate tools--eclipse反向工程

1.前言 最近在做專案的時候,總是要單獨建立資料庫表的xx.java 檔案以及對應的xx.hbm.xml檔案,手動的話比較麻煩,網上百度說大部分的都是myeclipse的內嵌工具,eclipse沒有對應的jar,研究了一下,發現hibernate tools可

Github Config for Eclipse

upd load mage ima png cnblogs lips config 虛擬 搭建了虛擬機供練手用,想要保存練習代碼,於是想在VM Eclipse上配置Github,從此隨練隨保存。 步驟:1. eclipse ->help->install new

hibernate框架在eclipse下的配置方法(一)

java、 sql數據庫 文件目錄 測試表 any 配置 包名 ive 當我 一、ORM O:object 對象 R:Realtion 關系(關系型數據庫) M:Mapping 映射 ORM:對象關系型映射   目前流行的編程語言,如Java、C# ,它們都是面向對象的編程

【微軟大法好】VS Tools for AI全攻略(2)

port shell orf 方式 virt cnblogs 我們 玩耍 虛擬 接著上文,我們來討論如何使用Azure資源來訓練我們的tensorflow項目。Azure雲我個人用得很多,主要是因為微軟爸爸批了150刀每月的額度,我可以愉快地玩耍。 那麽針對Azure,有成

Could not open Hibernate Session for transaction

log ips mysq eclipse nat password image post session web項目導入eclipse之後一直打不開,連接不上mysql報錯。後來高人指點,原因是文件配置的問題。 打開文件: 因為我的mysql沒有設置密碼,所以我這裏的pa