課程
/后端開(kāi)發(fā)
/Java
/Hibernate初探之單表映射
myeclipse10沒(méi)法安裝hibernate tool也沒(méi)法自動(dòng)生成hbm.xml
2016-10-25
源自:Hibernate初探之單表映射 1-10
正在回答
我的myeclipse運(yùn)行成功了,
1.首先連接數(shù)據(jù)庫(kù),在myeclipse的右上角沒(méi)有模糊的按鈕
2.選擇myeclipse DataBase Explorer
3.在空白處點(diǎn)擊右鍵點(diǎn)擊new按鈕
4.如下圖,自己配置好。
5.按下圖,直接點(diǎn)擊next。
6.按下圖,再次點(diǎn)擊next。
7.點(diǎn)擊finish。
然后生成了Students.hbm.xml文件。
最后按下面修改一下自動(dòng)生成的Students.hbm.xml,修改成如下的代碼:
<hibernate-mapping>
? ? <class name="Students" table="students" catalog="hibernate">
? ? ? ? <composite-id>
? ? ? ? ? ? <key-property name="sid" type="java.lang.Integer">
? ? ? ? ? ? ? ? <column name="sid" />
? ? ? ? ? ? </key-property>
? ? ? ? ? ? <key-property name="sname" type="java.lang.String">
? ? ? ? ? ? ? ? <column name="sname" length="20" />
? ? ? ? ? ? <key-property name="gender" type="java.lang.String">
? ? ? ? ? ? ? ? <column name="gender" length="2" />
? ? ? ? ? ? <key-property name="birthday" type="java.sql.Timestamp">
? ? ? ? ? ? ? ? <column name="birthday" length="19" />
? ? ? ? ? ? <key-property name="address" type="java.lang.String">
? ? ? ? ? ? ? ? <column name="address" length="100" />
? ? ? ? </composite-id>
? ? </class>
</hibernate-mapping>
最后,一旦 自動(dòng)生成了Students.hbm.xml,,,hibernate.cfg.xml會(huì)自動(dòng)添加這行代碼
<mapping resource="./Students.hbm.xml" />
WOshows 提問(wèn)者
下載tool沒(méi)成功
下載好hibernate組件,然后點(diǎn)eclipse 里的help,----install newsoftware,---add ? 然后選擇location 和name,next ,next , finish.就完成了
舉報(bào)
Java持久化框架Hibernate入門教程,掌握Hibernate基本概念
3 回答請(qǐng)問(wèn)myeclipse 怎么生成 hbm 文件
1 回答怎么自動(dòng)生成映射文件???
4 回答Myeclipse怎么生成這個(gè)對(duì)象關(guān)系映射文件?
3 回答主鍵自動(dòng)生成問(wèn)題
2 回答MyEclipse如何自動(dòng)創(chuàng)建表
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-08-28
我的myeclipse運(yùn)行成功了,
1.首先連接數(shù)據(jù)庫(kù),在myeclipse的右上角沒(méi)有模糊的按鈕
2.選擇myeclipse DataBase Explorer
3.在空白處點(diǎn)擊右鍵點(diǎn)擊new按鈕
4.如下圖,自己配置好。
5.按下圖,直接點(diǎn)擊next。
6.按下圖,再次點(diǎn)擊next。
7.點(diǎn)擊finish。
然后生成了Students.hbm.xml文件。
最后按下面修改一下自動(dòng)生成的Students.hbm.xml,修改成如下的代碼:
<hibernate-mapping>
? ? <class name="Students" table="students" catalog="hibernate">
? ? ? ? <composite-id>
? ? ? ? ? ? <key-property name="sid" type="java.lang.Integer">
? ? ? ? ? ? ? ? <column name="sid" />
? ? ? ? ? ? </key-property>
? ? ? ? ? ? <key-property name="sname" type="java.lang.String">
? ? ? ? ? ? ? ? <column name="sname" length="20" />
? ? ? ? ? ? </key-property>
? ? ? ? ? ? <key-property name="gender" type="java.lang.String">
? ? ? ? ? ? ? ? <column name="gender" length="2" />
? ? ? ? ? ? </key-property>
? ? ? ? ? ? <key-property name="birthday" type="java.sql.Timestamp">
? ? ? ? ? ? ? ? <column name="birthday" length="19" />
? ? ? ? ? ? </key-property>
? ? ? ? ? ? <key-property name="address" type="java.lang.String">
? ? ? ? ? ? ? ? <column name="address" length="100" />
? ? ? ? ? ? </key-property>
? ? ? ? </composite-id>
? ? </class>
</hibernate-mapping>
最后,一旦 自動(dòng)生成了Students.hbm.xml,,,hibernate.cfg.xml會(huì)自動(dòng)添加這行代碼
<mapping resource="./Students.hbm.xml" />
2016-10-25
下載tool沒(méi)成功
2016-10-25
下載好hibernate組件,然后點(diǎn)eclipse 里的help,----install newsoftware,---add ? 然后選擇location 和name,next ,next , finish.就完成了