1.å¨Myeclipse8.5å¦ä½å®è£
Jython
å¨Myeclipse8.5å¦ä½å®è£ Jython
æ¹æ³ä¸
å¯å¨ææ°çElcipseï¼eclipse-jee-ganymede-SR1-win.zipï¼ï¼éæ©Helpï¼Software Updatesï¼æå¼Available Softwareé项å¡ï¼ç¶ååå»Add Sites åå«è¾å ¥JBoosçå·¥å ·åHibernateå·¥å ·å¨çº¿å®è£ å°åï¼ç¶åéæ©å®è£ Hibernate ToolsJboos åTools Development Release
çå¾ å®è£ æåï¼å®è£ è¿ç¨å è¦ä¸è½½ä¸å°Jarå ï¼è§ä½ çç½ç»é度ä¸åï¼éè¦çæ¶é´ä¸åï¼å®è£ å®æ¯Eclipseå°æç¤ºä½ éæ°å¯å¨ï¼éå¯Eclipseå®è£ å®æã(注æï¼å å®è£ Hibernate Toolsæååï¼åå®è£ Jboos Tools Development Release)
æ¹æ³äº
ä¸è¬æè¿æ¯å欢ä¸è½½æéçæ件åèªå·±é ç½®ï¼ è¿æ ·å¯ä»¥å¯¹Hibernate Myeclipseæ件è¿è¡ç®¡çãæ¹æ³å¦ä¸ï¼
ä¸è½½æéçHibernatetools http://www.hibernate.org/6.html
å°ä¸è½½å¾å°çæ件解åå¾å°featuresåpluginsæ件夹ï¼å¨eclipseå®è£ ç®å½éæ°å»ºaddPluginsæä»¶å¤¹ï¼ åæ¶å¨addPluginsæ件夹ä¸å»ºç«Hibernatetoolsæ件夹,源码qq空间源码网站源码 å°ä¸¤ä¸ªæ件夹(featuresåplugins)å¤å¶å°Hibernatetoolsç®å½ä¸ï¼ç¶åå¨eclipseç®å½ä¸å»ºç«linksæ件夹ï¼å¨linksæ件夹ä¸å»ºç« hibernatetools.linkæ件, æå¼è¯¥æ件è¾å ¥ Hibernatetoolsçç»å¯¹ç®å½ã
æçæ件夹å¦ä¸æ示
D:\java\plateform\eclipse_jee\eclipse\addPlugins\hibernatetools
D:\java\plateform\eclipse_jee\eclipse\links
linksæ件夹çhibernatetools.linkæ件å 容å¦ä¸
path=D:/java/plateform/eclipse_jee/eclipse/addPlugins/hibernatetools
è¿æ ·éæ°å¯å¨eclipseå³å¯
æ°å»ºä¸ä¸ªå·¥ç¨MyHibernateï¼ç¶åç¶åéæ©Fileï¼Newï¼Hibernate Configuration File(cfg.xml)ï¼æå¼å建Hibernateé ç½®å导ï¼æè¿éé ç½®äºä¸ä¸ªSQL Serveræ°æ®åºï¼éä¸Create a console configuration å¤é项ï¼ä»¥æ¤é ç½®æ件å建Hibernateæ§å¶å°é ç½®ã
å建Hibernate Console Configurationå导æMainãOptionãClasspathãMappingsãCommonäºä¸ªé项å¡ï¼å¦æä½ å¨å·¥ç¨ä¸å·²ç»å¼å ¥äºJDBC驱å¨åï¼ç´æ¥ç¹å»Finishå®æå³å¯ï¼ä»¥åå¨å®æå ¶ä»é ç½®ã
å®æåï¼ä½ å°±å¯ä»¥å¨Hibernate Configurationè§å¾çªå£çå°é 置项ï¼å·²ç»é¾æ¥å°æ°æ®ï¼å¹¶æä½ æ°æ®åºä¸ç表ååºæ¥ï¼å¦æå¨è¿ä¸æ¥ä½ 没ææåçè¯ï¼è¯·æ£æ¥ä½ æ¯å¦ä»¥æ£ç¡®å®è£ çHibernate ToolsåJBoos Toolsè¿ä¸ªå¾éè¦ï¼å¦å¤å¦ææ示æ¾ä¸å°JDBC驱å¨çè¯ï¼è¯´æä½ å·¥ç¨çclasspathä¸æ²¡æJDBC驱å¨jarå ï¼å è½½æ£ç¡®ç驱å¨å³å¯ã
å¦æä½ ä¸è½çå°ä¸å¾æ示çHibernate Configurationsçªå£ï¼è¯´æä½ æ²¡ææå¼è¿ä¸ªViewï¼éæ©Windowsï¼Show Viewï¼Otherï¼ç¶åéæ©Hibernate Configurationså³å¯æå¼è¿ä¸ªçªå£ï¼çªå£çä½ç½®æ å ³ç´§è¦ï¼ä½ å欢æ¾å¨é£éå°±æä»æè¿å»ã
ä¸é¢å°ä»ç»å¦ä½ä½¿ç¨Hibernate Code Generationæ¥äº§çæ°æ®åºè¡¨æ å°Java对象ï¼é¦å è¦å¨æ°æ®åºä¸å建表ï¼å¹¶è®¾ç½®å·å段åå主é®ï¼ä¸»é®å¾éè¦ï¼å ³äºä¸»é®çéæ©å»ºè®®ä½ 使ç¨ä¸ä¸å¡æ å ³çIDä½ä¸ºä¸»é®ï¼ï¼æå¼Hibernateè§å¾æ¾å°Hibernateè¿è¡å¾æ ä¸çHibernate Code Generation Configurationsï¼å¦ææ¾ä¸å°è¿ä¸ªå¾æ 说æ没æå¨Hibernateè§å¾ä¸ã
é ç½®ä¸ä¸ªæ°çé 置项ï¼è¾å ¥é 置项çå称MyHibernateCodeï¼éæ©Hibernate Configurationï¼å³å·²é 好çHibernateæ§å¶å°é ç½®ï¼ï¼å¨Output directoryä¸è¾å ¥åå代ç è¾åºç®å½ï¼æ³¨æè¿ä¸ªç®å½ä¸è¬åªé项ç®çæºä»£ç srcï¼ï¼ç¶åå¤éReverse engineer from JDBC connectionï¼å¨Packageä¸è¾å ¥å åï¼ä½ è¦åæ¾å°srcä¸é£ä¸ªå ä¸ï¼ï¼æååå»Setupï¼Create Newæå¼Reverse engineeré ç½®å导ï¼éæ©é ç½®åå¨ä½ç½®ï¼ææ¾å°äºsrcç®å½ä¸ï¼ï¼æåéæ©è¦ååå·¥ç¨ç表ï¼å¦å¾ï¼
å¦æä½ çDatabase schemaä¸æ²¡æ项ç®ï¼æ¥çä½ éæ©Console configurationæ¯å¦æ£ç¡®ï¼åå»ä¸é¢âRefreshâåºè¯¥å°±åºæ¥äºï¼æååå»Finishå®æè¿åï¼
ç¶ååå»Exportersé项å¡ï¼éæ©å¯¼åºé¡¹ç®ï¼è¿ééæ©äºDomain code(.java) åHibernate XML Mappings(.hbm.xml)ï¼å 为使ç¨çJDKçæ¬è¾é«å æ¤å¤éUse Java 5 syntax项ãRefreshåCommon项å¯ä¸è¿è¡è®¾ç½®ï¼æååå»Runè¿è¡ï¼äº§ç代ç ã
产çç代ç åé ç½®æ件ï¼å¦å¾ç¤ºï¼ä»£ç èªå¨äº§çåè¿éè¦ä½ æ ¹æ®èªå·±çä¸å¡é»è¾æ£æ¥ä¸ä¸ï¼å¹¶æä½ çDAOæ¶æå®æï¼Hibernate Toolså°è¿éå·²ç»å¸®ä½ å®æç大éç¼ç å·¥ä½ã
以ä¸æ¯å¯¹Hibernate Myeclipseæ件çç®åä»ç»ï¼å¸æ读è è½å¤å¯¹Hibernate Myeclipseæ件ææ´å¤çç解ã