版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
PAGE大连交通大学信息工程学院毕业设计(论文)任务书题目后现代住宅销售与服务系统任务及要求:1.设计(研究)内容和要求任务:调查电子商务技术发展近况,完成实习报告,字数不少于3000,第三周交给指导老师。结合自己实习情况安排进度,填写进度计划表,第二周完成后交给指导老师签字,并严格执行。按照软件工程思想,独立完成系统的设计和程序开发,完成代码估计2000行左右。用JSP技术实现后现代住宅定制与服务的功能。程序简洁,算法可行,运行情况良好。要求:每周和指导老师至少见面沟通一次,回报课题进展情况,接受老师询问。接到任务书后,查阅与题目及专业相关的外文资料进行翻译,要求不少于10000个外文字符,译出汉字不得少于3000,于第四周交给指导老师审阅。毕业设计第13周完成毕业论文的装订,并由指导老师评阅。论文要求12000字以上,包括综述、系统总体设计、系统实现、性能分析、结论等。教学第13周通过中软及教研室组织进行软件验收,验收时要提供软件使用说明书。于第13周提出毕业答辩申请并签字。第14周答辩,要求制作PPT2.原始依据通过大学几年的学习,已经学习了诸如软件工程、数据库原理及应用、数据结构、C++、VisualBasic、JAVA等多门程序设计语言和网络等基础知识和专业知识,学生有能力而且可以独立完成小中型项目的设计与开发。学校现有设备和环境可以提供给学生实习和上机,而且具有专业老师可以指导学生。3.参考文献[1]汪孝宜.刘中兵.徐佳晶等编著.JSP数据库开发实例精粹[M].北京:电子工业出版社.2005[2]姚晓春.郑文清编著.Java编程技术教程[M].北京:清华大学出版社.1999[3]吴逸贤.吴目诚编著.Java2程序设计[M].北京:科学出版社.2003[4]飞思科技产品研发中心编著.Jsp应用开发详解[M].北京:电子工业出版社.2006[5]周竞涛.赵寒.王明微.等编著.Eclipse完全手册[M].北京:电子工业出版社.2006[6]张文静.林琪译.JSP程序设计.北京:人民邮电出版社[M].2006[7]孙卫琴.李洪成著.Tomcat与JavaWeb开发技术祥解[M].北京:电子工业出版社.2006[8]BruceEckel著.ThinkingInJava[M].北京:机械工业出版社.2006[9]陈威.白伟明.李楠著.JSP工程应用与项目实践[M].北京:机械工业出版社.2005[10]宋昆.李严著.SQLServer数据库开发实例解析[M].北京:机械工业出版社.2006指导教师签字:教研室主任签字:2012大连交通大学信息工程学院毕业设计(论文)进度计划与考核表学生姓名金双阳专业班级软件工程08-2班指导教师王鑫翟悦本课题其他人员无题目后现代住宅销售与服务系统日期计划完成内容完成情况指导老师检查签字第1周实习调研,查阅课题相关外文资料第2周了解行业状况、查阅文献资料,阅读资料,撰写调研报告第3周完成10000字符或3000汉字以上外文翻译资料,准备资料,学习JSP技术第4周进行需求分析第5周进行概要设计第6周进行概要设计,基本框架完成,提交毕业论文提纲第7周完成后台数据库的设计并编码,完成部分论文第8周完成后台数据库的设计并编码,完成部分论文第9周继续编码并进行测试,继续编写毕业设计论文第10周继续进行程序测试,继续编写毕业设计论文第11周整理资料、文档、图表等,修改毕业设计论文第12周完成毕业设计论文,打印,按要求装订第13周软件验收和准备毕业设计答辩第14周毕业设计答辩及成绩评定指导教师签字:年月日注:“计划完成内容”由学生本人认真填写,其它由指导教师考核时填写。大连交通大学信息工程学院毕业设计(论文)调研报告学生姓名金双阳专业班级软件工程08-2班指导教师王鑫翟悦职称高工讲师所在单位信息科学系软件工程教研室教研室主任刘瑞杰完成日期2012年4月6日实习报告1课题来源及意义如今,计算机网络技术已经深入到人们生活的各个方面,许多传统的事务以不再局限于纯物质形态,转而延伸到虚拟的网络平台上,房屋租售的交易也是如此。房屋租赁机构是我国的改革开放过的程中起步最早的、开拓发展最快、收效最为明显、市场化程度高的服务行业之一。在我国经济迅猛发展,全国各大城市人口对住房条件要求逐渐提高的情况下,房屋租赁机构要面临着待租售房源数量增长,求购求租人群多样化等问题,如何用先进的管理手段,提高房屋租赁机构的管理水平和服务质量已成为该行行业的当务之急。采用计算机网络进行房屋租赁管理,可以及时更新房源信息,很大程度上提高租赁机构的管理效率、改善服务水准。因此,设计和开发网络房屋交易系统具有十分重要的现实意义。电子商务是一个发展潜力巨大的市场,极具有发展前景。电子商务双向信息沟通、灵活的交易手段和快速的交货方式的特点,将给社会带来巨大的经济效益,促进整个社会的生产力的提高。电子商务的广泛推广,打破了时空限制,改变了贸易形态,大大加速了整个社会的商品流通,有助于降低企业成本,提高企业竞争力,尤其能够使中小型企业直接进入国际市场参与国际市场竞争。电子商务给消费者提供了更多的选择,提供了更好的便利性。它是商务领域的一场信息革命,它对我们的思维方式、对人类的经济活动、对人类的工作方式和生活方式都将产生根本性的影响。新技术的出现与应用,总会带来一系列的变革,我们现在处于工业化相信细化转轨的过程中。网络的出现与迅速发展,电子商务的逐渐成熟,不仅改变了我们记录和传播知识的符号、改变了我们的交易方式,而且将对我们的思维方式、对我们的工作方式和生活方式都将产生根本性的影响。该房屋信息发布系统也是基于B/S模式的电子商务的应用。2国内外的现状在国外,计算机科学技术已经是一门比较普遍的技术。计算机的最开始发展是在美国。所以现在美国的计算机技术是世界上最先进的国家。在他们国家的工业,产业中,计算机不仅仅是一门技术,更始一种国家的支柱产业。依托计算机产业,每年都会产生巨大的经济利益和社会利益。计算机和通讯技术。是先进发达国家的带名词,在任何一个角落,都会看到这门技术的存在。世界上的500强企业中,不缺乏微软、IBM这样的高科技技术公司,也同样有沃尔玛、家乐福这样的零售业公司。他们不只是发展自己的优势项目,而是把这两个最先进的项目结合起来。而一般的管理系统,正是他们的热门技术。几乎所有的单位和公司都需要这样的小管理系统。这也是以后的发展趋势。不仅节约资金和产品的宣传成本,更可以用最低的价格去吸引消费者的眼球。使他们公司的业绩越来越好。我生活的城市在大连,大连现在的房屋交易机购已经很成熟了,各种房屋租售网站也是层出不穷。经过调查,例如:大连天健网、大连易居网、搜房网、看房网都是很不错的房屋交易网站。大连天健网以论坛的形式被广大市民所熟知,该网站的开发管理者的精心更新维护使其逐步完善,现在天健网已经发展成一个多元化的信息网站,房屋交易系统模块因房源信息量大,更新快被受关注;看房网是一个新建立的网站,以新颖的房源视频模式吸引广大市民的关注,房源信息用视频短片的形式呈现给浏览者,这样有意求购求租的浏览者便可直观的清楚各个房源的基本情况,不必东奔西走,既省时又省力。3本课题的研究目标本课题主要对房屋交易系统的现状进行调研分析,实现网上房屋交易系统的各个功能模块,为以后实现大型房屋交易平台打好基础。本系统设计开发完成后必能够实现各种房屋信息的在线交易。达到层次清晰,功能丰富的要求;界面美观,用户操作界面采用中文汉字操作,使用起来较为方便,操作灵活;本系统的开发具有良好的可扩充性,可根据房源信息交易的需要随时补充和修改;系统维护简单方便。4研究内容本系统为房屋租赁信息发布系统,属于电子商务的范围,就是通过查询、发布房屋租赁信息,并取得联系方式,完成房屋交易。系统主要分为两大部分,一是前台部分,主要完成网上信息浏览,二是后台数据库的连接,而数据库部分是本系统的重要部分。前台房源查询,发布,修改都是基于后台数据库得以实现,本系统主要功能包括首页设计、房源信息页、用户管理页等。本系统设计完成后,最终将能实现以下功能:(1)用户注册;(2)用户管理(发布房源信息、房源查询、个人信息修改);(3)房屋买卖或房屋租赁;(4)留言板管理、便民问答。5使用的主要技术(1)JSP技术JSP全称JavaServerPages,它是由SunMicrosystems公司提出、许多公司参与建立的一种动态网页技术标准。它诞生在1999年6月1日。用JSP开发的Web应用是
跨平台的,即能在Linux下运行,也能在其他操作系统上运行。目前国内外已经在广泛地使用JSP。随着JAVA语言得到普及,越来越多的公司开始关注JSP的前景。(2)SQLServer2000SQLServer2000是由Microsoft公司开发的,简称SQLServer,由一系列相互协作的组件构成,能满足最大的Web站点和企业数据处理系统存储和分析数据的需求。(3)TomcatTomcat是一个免费的开源的Serlvet容器,它是Apache基金会的Jakarta项目中的一个核心项目,由Apache,Sun和其它一些公司及个人共同开发而成。由于有了Sun的参与和支持,最新的Servlet和Jsp规范总能在Tomcat中得到体现。6可行性分析(1)技术可行性B/S结构的信息管理系统发展至今,业务逻辑的分析和开发技术都已经比较成熟。首先B/S的开发模式在各个行业都有较好的应用。JSP、Struts、SQLServer等技术对WEB页面的开发都有较好的支持。业务逻辑的处理,及相应的数据存储的技术都已经很完备。且这些技术通过查阅相关书籍都较容易获取及学习。相应的开发环境通过互联网也都可以获取。所以综合这些方面,本网络房屋交易系统满足技术可行性。(2)经济可行性由于本系统框架结构简单,规模不大,在系统开发及运行过程中仅需要支付少量开发成本,及服务器架设成本和系统运行时的维护成本。完成后的系统将本市的房源信息全面地介绍给广大市民,满足广大房屋求租求购的需求,提高房屋租赁机构的工作效率。据此对投资和收益的权衡比较,确定网络房屋交易系统具有经济可行性。(3)操做可行性实现系统之后,要由1~2名计算机专业技术人员看管服务器和进行技术支持。而用户只需坐在装有调制解调器的PC机前,就可以畅游在网络空间里搜寻自己感兴趣的房源信息。综上所述,该系统的开发是可行的。7己具备的实验条件(1)计算机硬件环境:CPU:IntelCore2DuoT64002.0GHz内存:2048MB硬盘:160G(2)计算机软件环境:操作系统:MicrosoftWindowsXPProfessionalSP2JSP服务器:Tomcat5.5.20数据库:MicrosoftSQLServer2000浏览器:MicrosoftInternetExplorer7.08进度安排题目后现代住宅销售与服务系统日期计划完成内容第一周实习调研,查阅课题相关外文资料第二周了解行业状况、查阅文献资料,阅读资料,撰写调研报告第三周完成10000字符或3000汉字以上外文翻译资料,准备资料,学习JSP技术第四周进行需求分析第五周进行概要设计第六周进行概要设计,基本框架完成,提交毕业论文提纲第七周完成后台数据库的设计并编码,完成部分论文第八周完成后台数据库的设计并编码,完成部分论文第九周继续编码并进行测试,继续编写毕业设计论文第十周继续进行程序测试,继续编写毕业设计论文第十一周整理资料、文档、图表等,修改毕业设计论文第十二周完成毕业设计论文,打印,按要求装订第十三周软件验收和准备毕业设计答辩第十四周毕业设计答辩及成绩评定
9参考文献[1]张跃平.JSP实用教程[M].北京清华大学出版社.2003[2]SunMicrosystems.DatabaseProgrammingWithJavaTechnology[M].2001[3]JavaServlet&JSPCookbook[M].O'ReillyPress.2004[4]万峰科技编著.JSP网站开发四酷全书[M].电子工业出版社.2005[5]武卫华.计算机专业英语[M].科学出版社.2004[6]王国辉.李文立.杨亮.JSP数据库系统开发完全手册[M].北京人民邮电出版社.2006[7]吴斌.赵有珍等.SQLServer应用与提高[M].科学出版社.2002[8]王利.数据库基础与应用[M].北京中央广播电视大学出版社.1997[9]高阳.数据库技术与应用[M].电子工业出版社.2003[10]汪孝宜.刘中兵.徐佳晶.JSP数据库开发实例精粹[M].电子工业出版社.2005[11]王诚梅.袁然.王艳.JSP案例开发集锦[M].电子工业出版社.2005大连交通大学信息工程学院毕业设计(论文)外文翻译学生姓名金双阳专业班级软件工程08-2班指导教师王鑫翟悦职称高工讲师所在单位信息科学系软件工程教研室教研室主任刘瑞杰完成日期2012年4月13日WorkingwithHibernateinEclipseIntroductionIrecentlystartedusingEclipseasmydevelopmentenvironment,inpartbecauseofitssupportforthemanyplatformsonwhichIdevelop,andinpartbecauseEclipseisagreatexampleofthepowerofanopen,extensibleenvironmentinwhichpeopleallaroundtheworldcancontribute.I'mbeginningtoinvestigatetheextensionspeoplehavecomeupwith.Forexample,IusealittleplugincalledXMLBuddytoworkwithXMLfiles,andit'sveryhelpful.SoIbecamecuriousaboutwhetheranyonehadwrittenpluginstoworkwithHibernate,sinceI'vedonesomuchofthatrecentlyinputtingtogethertheDeveloper'sNotebook.Itturnsoutthereareseveralsucheffortsunderway;inthisarticlewewillexploreoneofthem--theHibernateSynchronizer.HibernateSynchronizerOfthepluginsI'vefoundsofar,theHibernateSynchronizerinterestedmemostbecauseitseemstobestsupportthekindofmapping-centricworkflowIadoptedthroughoutmyDeveloper'sNotebook.(Hibernatecanbeusedinmanydifferentways,socheckouttheotherpluginsavailable;thesemaybemorehelpfulifyourenvironmentcallsforanotherapproach.)Infact,theHibernateSynchronizerpluginremovestheneedforyoutothinkaboutupdatingyourJavacodewhenyouchangeyourmappingdocument.InaveryEclipse-likeway,itautomaticallyupdatestheJavacodeasyoueditthemapping.ButitgoesevenfartherthanHibernate'sbuilt-incodegenerationtoolsbycreatingapairofclassesforeachmappedobject.It"owns"abaseclass,whichitrewritesatwillasyouchangethemapping,andgivesyouasubclassthatextendsthisbaseclass,whereyoucanputbusinesslogicandothercode,withoutfearthatitwillevergetchangedoutfromunderyou.AsbefitsanapproachcenteredaroundtheHibernatemappingdocument,HibernateSynchronizerincludesaneweditorcomponentforEclipsethatprovidesintelligentassistanceandcodecompletionforsuchdocuments.AniceDTD-drivenXMLeditor,suchastheaforementionedXMLBuddy,candosomeofthisforyou,butHibernateSynchronizerusesitssemanticunderstandingofthedocumentstogomuchfurther.Italsooffersagraphicalviewofthepropertiesandrelationsinthemapping,"wizard"interfacesforcreatingnewelements,andothersuchniceties.And,asmentioned,initsdefaultconfigurationtheeditorautomaticallyregeneratesthedata-accessclassesasyouedittheirmappingdocuments.ThereareotherpiecestoHibernateSynchronizer,too.ItaddsasectiontoEclipse'sNewmenuthatprovideswizardsforcreatingHibernateconfigurationandmappingfiles,andaddscontextualmenuentriesinthepackageexplorerandinotherappropriateplaces,providingeasyaccesstorelevantHibernateoperations.OK,enoughabstractdescription,timetogetdowntothepracticalstuff!Afterall,youwerealreadyprobablyinterestedinthis,oryouwouldn'thavestartedtoreadthearticle.SohowdoyougetandplaywithHibernateSynchronizer?InstallationHibernateSynchronizerisinstalledusingEclipse'sbuilt-inUpdateManager.ThepluginoffersseparateupdatesitesforusersofEclipse2.1andtheforthcomingEclipse3.BecauseI'musingEclipseformission-criticalwork,I'mstillusingtheproductionrelease,2.1.AsIwritethis,Eclipse3hasenteredits"releasecandidate"phase,andIamverymuchlookingforwardtobeingabletoupgradetoaproductionreleaseofversion3whenIreturnfromJavaOnelaterthissummer.(ThemainreasonImentionthisistoemphasizethatthefollowinginstructionsarewrittenfromanEclipse2perspective;somecommandsandscreensareundoubtedlydifferentinEclipse3,soifyou'reusingit,besuretoapplyyourownjudgmentinfollowingthesesteps!Ifithelps,myimpressionisthatHibernateSynchronizer'sowninstallinstructionsarewrittenforEclipse3.)FireupEclipseandopentheUpdateManagerbychoosingHelp->SoftwareUpdates->UpdateManager.OncetheInstall/Updateperspectiveopensup,right-click(orcontrol-click,ifyou'reusingaone-buttonmouse)intheFeatureUpdatesviewandchooseNew->SiteBookmark.Figure1.AddingtheHibernateSynchronizerpluginsitetotheUpdateManagerIntheresultingdialog,entertheURLfortheversionofthepluginthatyouneed.TheURLtobeentereddependsonyourEclipseversion:Eclipse2.1:/hibernatesync/eclipse2.1Eclipse3:/hibernatesyncYoualsoneedtoassignanameforthenewbookmark."HibernateSynchronizer"makesalotofsense.OnceyouclickFinish,thenewbookmarkwillappearintheFeatureUpdatesview.Toactuallyinstalltheplugin,clickonthedisclosuretriangletotheleftofthebookmark,andagainonthenextonethatappearsinsideofit,untilyoucanseetheiconforthepluginitself.Whenyouclickonthat,thePreviewviewwillupdatetoshowyouaninterfacethatallowsyoutoinstalltheplugin.ClickInstallNowtoactuallyinstallit,andletEclipsewalkyouthroughtheprocess.SeeTrade-Offs,below,forsomediscussionaboutthislicenseagreement.YoumaywishtoreaditcarefullybeforedecidingtouseHibernateSynchronizerinaprojectofyourown.Ithinkit'sprobablyfine,butitisconfusinglybasedontheGPLwithoutactuallybeingopensource.Nowthatthepluginisinstalled,youneedtoquitandrelaunchEclipseforittotakeeffect.ThedialogseemstoimplythatEclipsewillrestartitself,butinmyexperience,clickingYesmerelycausestheenvironmenttoquit,andyouhavetorelaunchitmanually.ThismaybealimitationofEclipse2.1'sMacOSXimplementation;Eclipse3isgoingtobethefirstreleasethatpromises"first-class"supportforOSX.Inanycase,thisisaveryminorissue.IfyouneedtorestartEclipse,dosonow,becauseit'stimetostartconfiguringtheplugintoputitthroughitspaces!ConfigurationOnceEclipsecomesbackup,youcanclosetheInstall/Updateperspective.OpenaJavaprojectthatusesHibernate.Ifyou'vebeengoingthroughtheexamplesintheDeveloper'sNotebook,you'llhaveseveraldirectoriesfromwhichtochoose.I'llbelookingattheexamplesastheyexistinChapter3,whichisthesamplechapteravailableonline.Youcanalsodownloadthesourceforalloftheexamplesfromthebook'ssite.Ifyou'recreatinganewEclipseprojecttoworkwithoneoftheexamplesourcedirectories,justchooseFile->New->Project,specifythatyouwanttocreateaJavaprojectandclickNext,giveitaname("HibernateCh3"inmycase,asshowninFigure11),unchecktheUsedefaultcheckboxsothatyoucantellEclipsewheretofindtheexistingprojectdirectory,andhittheBrowsebuttontolocatewhereitexistsonyourowndrive.Atthispoint,youcanclickFinishtocreatetheproject,butIgenerallyliketoclickNextanddouble-checkthedecisionsEclipseismaking.(Ofcourse,ifitgetsanythingwrong,youcanalwaysgobackandfixtheprojectproperties,butItendtofinditdisconcertingtobegreetedbyatonoferrorsandwarningsimmediatelyifthereisalibrarymissingorsomething.)Inthiscase,mycautionwasunnecessary.Eclipsefiguredoutexactlyhowthedirectorywasstructuredandintendedtobeused,andfoundallofthethird-partylibrariesIhaddownloadedandinstalledinordertoenableHibernateandtheHSQLDBdatabaseenginetorun.(AdetailedwalkthroughofthisprocessisthebulkofChapter1ofmyDeveloper'sNotebook.)ThiskindofsmartadaptabilityisoneofthegreatfeaturesofEclipse.Figure12showsournewprojectopenandreadyforexperimentation.ItalsoshowsthatEclipsedoesn'tliketofitintoawindowsmallenoughforareasonablescreenshot;I'mgoingtohavetoworkwithpartialwindowcapturesfromthispointon.ThenextthingweneedtodoiscreateaHibernateconfigurationfilethatHibernateSynchronizercanuse.Thereisalreadyapertiesfileinthesrcdirectory,whichishowtheexamplesinthebookwork,butHibernateSynchronizeronlyworkswithHibernate'sXML-basedconfigurationapproach.Sowe'llneedtoreplicatethecontentsofpertiesintoanewhibernate.cfg.xmlfile.Onthebrightside,thisgivesusourfirstopportunitytoplaywithafeatureofHibernateSynchronizer,theconfigurationfilewizard.ChooseFile->New->Other,clickthenewlyavailableHibernatecategory,pickHibernateConfigurationFile,andclickNext.Whenthewizardstartsup,thedirectoryitofferstoputthefileintodependsonthefileyou'vecurrentlygotselectedinEclipse.Let'sbesuretoputitatthetop-levelsrcdirectoryalongsidethepropertiesversion,forconsistency.Fillintherestoftheinformationrequestedbythewizardtomatchthepropertiesversionoftheconfiguration,asshowninFigure14.Noticethat,unlikewhenusingAnttocontroltheexecutionofHibernate(whichwastheapproachusedintheDeveloper'sNotebook),wehavenowaytocontrolthecurrentworkingdirectorywhenHibernateisinvoked,soweneedtouseafullyqualifiedpathtothedatabasefileintheURL.Inmycase,thistakesthe(somewhatungainly)valuejdbc:hsqldb:/Users/jim/Documents/Work/OReilly/Hibernate/Examples/ch03/data/music.(IfanyonecantellmehowtogetEclipseorHibernateSynchronizertouseaparticularworkingdirectoryforaproject,I'dcertainlybeinterested.I'mstillabeginnerwhenitcomestoEclipse,soitwouldnotsurprisemeatalltolearnthatthisispossibleandthatIsimplydon'tknowhowtodoit.)FillingintheDriverClassisalittlestrange:YouneedtoclicktheBrowsebutton,andstarttypingthedrivername.Ifyoutype"jdbcD",thewindowwillpresentonlytwochoices,andyoucaneasilyclicktherightone.YoucanclickFinishtocreatetheconfigurationfile.HibernateSynchronizerisnowreadytouse.ItopensthefileitcreatedsoyoucanseethestructureanddetailsofanXMLconfigurationfileforHibernate.Aquickwaytotestthattheconfigurationisworkingistoplaywiththeotherwizardinterface.ChooseFile->New->Other,clickthenewlyavailableHibernatecategory,pickHibernateMappingFile,andclickNext.Whenthewizardcomesup,itshouldbepopulatedwiththesettingsinformationwejustentered,andyoucanclicktheRefreshbuttontomakesureitcancommunicatewiththedatabaseandshowyouthatitfoundaTRACKtable.Thefirsttimeyoudothis,youmighthavetoconfirmthelocationofthe.jarfilecontainingtheHSQLDBdriver,forsomereason,butthatseemstohappenonlyonce.Inanycase,onceyouconfirmthateverythingseemstobeworking,clickCancelratherthanactuallycreatingthemapping,becausewewanttoworkwithourhand-createdmappingfilethatalreadyexists.GeneratingCodeThisisprobablythepartyou'vebeenwaitingfor.Whatcoolstuffcanwedo?Well,rightawaythereisanewcontextualmenuentryavailableforHibernatemappingdocuments.Ifyouright-click(orcontrol-click)onone,yougetanumberofHibernate-relatedchoices(Figure17),includingonetosynchronize.ThisisamanualwaytoaskHibernateSynchronizertogeneratethedataaccessobjectsassociatedwiththemappingdocument.TheAddMappingReferencechoiceisalsouseful:itaddsanentrytothemainHibernateconfigurationfiletellingitaboutthismappingdocument,soyoudon'tneedtoputanythinginyoursourcecodetorequestthatthecorrespondingmappinggetssetup.Fornow,let'slookattheresultofchoosingSynchronizeFiles.Thisiswherethingsstarttogetinteresting.Weendupwithtwonewsub-packages,oneforthe"base"dataaccessobjectsthatHibernateSynchronizer"owns"andcanrewriteatanytime,andoneforourbusinessobjectsthatsubclasstheseDAOs,whichwillnotgetoverwritten,andgiveusanopportunitytoaddbusinesslogictothedataclass.TherearemanymoreclassesgeneratedthiswaythanbyusingthenormalHibernatecodegenerationfacilities,whichhasadvantages,aswellassomepotentialdisadvantages,whichIdiscusslaterintheTrade-Offssection.Notealsothatinthepropertiesconfigurationforyourproject,youcanchoosewhichoftheseclassesgetgeneratedforyou,aswellasthepackagestructureintowhichtheyaregenerated.I'ddemonstratethis,butthecurrentreleaseofthepluginhasabugwhichblocksaccesstothisconfigurationinterfaceonMacOSX.Afixhasbeenmade,butnotyetreleased.BasedontheexamplesontheHibernateSynchronizerpage,Iputtogetherthefollowingclasstotryinsertingsomedataintothemusicdatabaseusingthesenewdataaccessobjects.It'squitesimilartotheversionusingthestandardHibernatecodegenerator(onpages39-40ofHibernate:ADeveloper'sNotebook)andevensimplerbecausetheclassesgeneratedbyHibernateSynchronizercreateandcommitanewtransactionforeachofyourdatabaseoperations,soyoudon'tneedanycodetosetoneupinsimplesituationslikethis.(Therearewaysofdoingsoifyouneedtohaveagroupofoperationsoperateasasingletransaction,ofcourse.)Here'sthecodeforthenewversion:HavingEclipsearoundwhileIwaswritingthiswasverynice.I'dforgottenhowmuchImissedintelligentcodecompletionwhileIwaswritingtheexamplesforthebook,andthereareseveralotherthingstheJDThelpswithtoo.TorunthissimpleprogramwithinEclipse,weneedtosetupanewRunconfiguration.ChooseRun->Run...withCreateTest2.javaasthecurrentlyactiveeditorfile.ClickonNewandEclipsefiguresoutthatwewanttorunthisclassinourcurrentproject,becausewecreateditwithamain()method.Thedefaultnameitassigns,CreateTest2,isfine.SinceIknewIdidn'tneedtouseJTA,IwonderedwhyHibernatewaseventrying.IopeneduptheHibernateconfigurationfile(Figure16)andlookedforanythingsuspiciousthatHibernateSynchronizerhadputthere.Sureenough,thereweresomelinesthatlookedlikeprimesuspects:OnceItriedcommentingtheseoutandrunningagain,thethirdtimewasindeedthecharm.Myruncompletedwithnoerrors,andmydataappearedinthedatabase.Hurrah!Runningthetrustyantdbtarget(explainedinChapter1oftheDeveloper'sNotebook)revealsthedatainallits(admittedlysimple)glory,asshowninFigure20.Ifyou'redoingthisyourself,besuretostartwithanantschematocreatethedatabaseschemaoremptyoutanytestdatathatmaybetherefrompreviousexperimentation.Figure20.ThedatacreatedbyourtestprogramNotethatyoucanrunAnttargetsfromwithinEclipsebyright-clicking(orcontrol-clicking)onthebuild.xmlfilewithinthePackageExplorer,choosingRunAnt,andpickingthetargetusinganEclipsedialog.Prettycool.Gettingdatabackoutusingqueriesisprettystraightforward,althoughthistimeit'salotclosertothesamecodeyou'dusewiththeordinaryHibernate-generateddataaccessclasses.EventhoughHibernateSynchronizergeneratesanumberofhelpermethodsforworkingwithnamedqueries,Idon'tthinkanyofthemisparticularlyuseful,becausetheyallinsistonrunningthequeryandreturningthelistofresults,ratherthangivingyoutheQueryobjecttoworkwithyourself.ThatpreventsyoufromusinganyofQuery'sconvenienttype-safeparametersettingmethods.Becauseofthat,Idecidedtosticktohavingthe_RootDAOobjectgivemeaHibernateSessiontoworkwiththe"oldfashioned"way.Infairness,IthinkIcouldeditthetemplatesusedbyHibernateSynchronizertogenerateanymethodsI'dlike,andwouldalmostcertainlylookintodoingthatifIwasgoingtoundertakeaprojectwithit.Actually,onfurtherreflection,becauseyoucanonlyworkwithaQuerywhileyou'vegotanactiveSession,themethodsofferedbytheDAOsalreadyworkthebestwaytheypossiblycan.You'realwaysgoingtohavetodoyourownsessionmanagementifyouwanttoworkwiththequerythewayIdointhisexample.Youcouldembedthesessionmanagementintothebusinesslogicprovidedin"your"halfoftheDAO,though,whichwouldgiveyouthebestofbothworlds.That'sanotherreasonthesplit-classmodelofferedbyHibernateSynchronizerissouseful.Iexplorethisinsightabitbelow.Anyway,here'sthecodeIfirstcameupwith,morallyquiteequivalenttothatonpages48-49ofthebook:ClearlythisistheapproachtotakewhenworkingwithnamedqueriesandHibernateSynchronizer.Aquicktestconfirmsthatitproducesthesameoutput,andit'smuchbettercode.WhetherornotyouwanttouseHibernateSynchronizertogenerateitsownstyleofdataaccessobjects,thereisonelastmajorfeaturetoexplore.EditingMappingsOneofthemainattractionsofHibernateSynchronizerisitsspecializededitorformappingdocuments.Thiseditorcanbeconfiguredtoautomaticallyregeneratetheassociateddataobjectswheneveryousavefiles,butthat'sjustafinaltouch;youmightwanttousetheeditorevenifyou'renotusingtheplugin'scodegenerator.Itgivesyousmartcompletionofmappingdocumentelements,andagraphicaloutlineviewinwhichyoucanmanipulatethem,aswell.Thereisatricktogettingtheeditortoworkforyou,though,atleastifyou'restartingfromthedownloadedsourcecodefrommyDeveloper'sNotebook.Inthedownload,themappingdocumentsarenamedwiththeextension".hbm.xml,"andtheeditorisonlyinvokedforfilesendingwith".hbm".Intheory,youcanconfiguretheextensionmappingswithinEclipsesothatbothextensionsusetheplugin'smappingdocumenteditor,butIwasn'tabletogetthattowork,andIsawthatsomeoneelseonthesupportforumhadthesameproblem.So,atleastfornow,yourbestbetmaybetorenamethefiles.(Ifyou'regoingtostickwithAnt-basedstandardcodegeneration,besuretoupdatethecodegentargetinbuild.xmltousethenewextension,too.)AssoonasIrenamedTrack.hbm.xmltoTrack.hbm,itsiconinthePackageExplorerwasupdatedtolookliketheHibernatelogo,andthedefaulteditorbecametheplugin's,asshowninFigure23.Forwhateverreason,theotherHibernateSynchronizeroptions(asshowninFigure17)areavailablewitheitherextension,buttheeditorisavailableonlywiththeshorterversion.Theeditorhascontext-sensitivecompletionsupportforalloftheelementsyou'readdingwithinthemappingdocument.Figure24showsacoupleofexamples,butnoscreenshotscanreallycapturethedepthandusefulnessofafeaturelikethis;I'dverymuchencourageyoutoinstallthepluginandplaywithityourselfforawhile.Youwillquicklyseehowhelpfulitcanbeinworkingwithmappingdocuments.Theoutlineview,showninFigure26,givesyouagraphicalviewofthehierarchyofclasses,theirmappedelements,namedqueries,andthelikethatarepresentinyourmappingdocument,aswellasgivingyouamenuofferingafewwizardstohelpyoucreatenewones.ThecontextualmenuwithintheeditoritselfalsooffersaFormatSourceCodeoptionyoucanusetocleanupandre-flowthedocument.Therearealreadymanyneatandusefulfeaturesinthiseditor,andit'llbeinterestingtoseehowitgrowsinthefuture.Myonlycomplaint(andaminoroneatthat)isthatthiseditorusesaverydifferentapproachtohelpingyoumanagequotationmarkswhenyoucompleteXMLattributesthantheJDTdoesinJavacode.Switchingbackandforthbetweenthemcanbesomewhatdisorienting.(ThewaytheJDTworkstakesalittlegettingusedtoitself,butonceyoustarttrustingit,it'salmostmagical.)Despitemyfirstimpressionthateverythingflowedfromthemappingdocument,HibernateSynchronizerdoesn'tcurrentlyofferanysupportforcreatingorupdatingadatabaseschemafromyourmappingdocuments.Therehasalreadybeenarequestpostedtothesupportforumaboutthis,anditwouldn'tsurprisemeifwesawthesefeaturesinthefuture;supportshouldn'tbetoodifficult.Fornow,you'llhavetostickwithanapproachliketheAnt-drivenoneinHibernate:ADeveloper'sNotebookifyou'redevelopingyourdatabasefromyourmappings.Alternately,theHibernatorplugindescribedbelowdoessupportschemaupdatesfromwithinEclipse.Imayhavetoinvestigatewhetherit'spossibletohavebothofthesepluginsinstalledatthesametime.Well,Icertainlyhopethiswhirlwindtourhasgivenyouansenseofthecapabilitiesofferedbytheplugin.Ihaven'tcoveredallofthem,byanymeans,sododownloaditandexploreonyourownifanythinghasintriguedyou.Trade-OffsClearlyyoucandosomeneatthingswithHibernateSynchronizer.WillIbeusingitformyownHibernateprojects?Therearesomeplusesandminusestothatidea,andIprobablywon'tdecideuntilIgettothepointofactuallyadoptingHibernateinplaceofourhomebrew(andverysimplistic)lightweightO/Rtoolatwork.Thatisgoingtobeasignificantenoughchangethatweareputtingit
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 园区大门主体结构验收评估报告
- 2026年学校听课评课实施方案
- 2026年网络安全防护技术发展趋势培训试卷含答案
- 2026年推普周活动工作计划
- 2026年学生工匠精神培育答辩题库完整版
- 2026年镇静催眠药物所致精神和行为障碍(中医神志病临床诊疗指南)
- 标准化动车组中间车体侧墙:轻量化设计与结构优化的深度剖析
- 柴油机变负荷工况下故障预警诊断技术的深度剖析与实践应用
- 柬埔寨吴哥高级中学孔子课堂汉语教学中文化教学:现状、问题与策略探究
- 柔性直流输电系统机电暂态建模及仿真软件开发:技术实践与创新
- (2025年)医师定期考核题库附答案
- 2026年建安杯信息通信建设行业安全竞赛重点题库(新版)
- 12《古诗三首》课件-2025-2026学年统编版语文三年级下册
- 短剧网络播出要求与规范手册
- 高二物理下学期期中考试试卷含答案
- 自建房安全施工合同协议书
- 《金属非金属地下矿山人员定位系统建设规范》
- JJG 693-2011可燃气体检测报警器
- 矿山生态修复治理实施方案
- 名著导读:《西游记》课件
- 抗美援朝战场上的感人故事三则
评论
0/150
提交评论