企业网站管理中英文翻译资料.doc_第1页
企业网站管理中英文翻译资料.doc_第2页
企业网站管理中英文翻译资料.doc_第3页
企业网站管理中英文翻译资料.doc_第4页
企业网站管理中英文翻译资料.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

understanding object/relational persistencethe approach to managing persistent data has been a key design decision in every software project weve worked on. given that persistent data isnt a new or unusual requirement for java applications, youd expect to be able to make a simple choice among similar, well-established persistence solutions. think of web application frameworks (jakarta struts versus webwork), gui component frameworks (swing versus swt), or template engines (jsp versus velocity). each of the competing solutions has advantages and disadvantages, but they at least share the same scope and overall approach. unfortunately, this isnt yet the case with persistence technologies,where we see some wildly differing solutions to the same problem. for several years, persistence has been a hot topic of debate in the java community.many developers dont even agree on the scope of the problem. is “persistence” a problem that is already solved by relational technology and extensions such as stored procedures, or is it a more pervasive problem that must be addressed by special java component models such as ejb entity beans? should we hand-code even the most primitive crud (create, read, update, delete) operations in sql and jdbc, or should this work be automated? how do we achieve portability if every database management system has its own sql dialect? should we abandon sql completely and adopt a new database technology, such as object database systems? debate continues, but recently a solution called object/relational mapping (orm) has met with increasing acceptance. hibernate is an open source orm implementation.hibernate is an ambitious project that aims to be a complete solution to the problem of managing persistent data in java. it mediates the applications interaction with a relational database, leaving the developer free to concentrate on the business problem at hand. hibernate is an non-intrusive solution. by this we mean you arent required to follow many hibernate-specific rules and design patterns when writing your business logic and persistent classes; thus, hibernate integrates smoothly with most new and existing applications and doesnt require disruptive changes to the rest of the application.this article is about hibernate. well cover basic and advanced features and describe some recommended ways to develop new applications using hibernate.often, these recommendations wont be specific to hibernatesometimes they will be our ideas about the best ways to do things when working with persistent data, explained in the context of hibernate. before we can get started with hibernate,however, you need to understand the core problems of object persistence and object/relational mapping. this chapter explains why tools like hibernate are needed.first, we define persistent data management in the context of object-oriented applications and discuss the relationship of sql, jdbc, and java, the underlying technologies and standards that hibernate is built on. we then discuss the socalled object/relational paradigm mismatch and the generic problems we encounter in object-oriented software development with relational databases. as this list of problems grows, it becomes apparent that we need tools and patterns to minimize thetime we have to spend on the persistence-related code of our applications. after we look at alternative tools and persistence mechanisms, youll see that orm is the best available solution for many scenarios. our discussion of the advantages and drawbacks of orm gives you the full background to make the best decision when picking a persistence solution for your own project.what is persistence?almost all applications require persistent data. persistence is one of the fundamental concepts in application development. if an information system didnt preserve data entered by users when the host machine was powered off, the system would be of little practical use. when we talk about persistence in java, were normally talking about storing data in a relational database using sql. we start by taking a brief look at the technology and how we use it with java. armed with that information, we then continue our discussion of persistence and how its implemented in object-oriented applications.relational databasesyou, like most other developers, have probably worked with a relational database.in fact, most of us use a relational database every day. relational technology is a known quantity. this alone is sufficient reason for many organizations to choose it. but to say only this is to pay less respect than is due. relational databases are so entrenched not by accident but because theyre an incredibly flexible and robust approach to data management.a relational database management system isnt specific to java, and a relational database isnt specific to a particular application. relational technology provides a way of sharing data among different applications or among different technologies that form part of the same application (the transactional engine and the reporting engine, for example). relational technology is a common denominator of many disparate systems and technology platforms. hence, the relational data model is often the common enterprise-wide representation of business entities. relational database management systems have sql-based application programming interfaces; hence we call todays relational database products sql database management systems or, when were talking about particular systems, sql databases.understanding sqlto use hibernate effectively, a solid understanding of the relational model and sql is a prerequisite. youll need to use your knowledge of sql to tune the performance of your hibernate application. hibernate will automate many repetitive coding tasks, but your knowledge of persistence technology must extend beyond hibernate itself if you want take advantage of the full power of modern sql databases.remember that the underlying goal is robust, efficient management of persistent data.lets review some of the sql terms used in this book. you use sql as a data definition language (ddl) to create a database schema with create and alter statements. after creating tables (and indexes, sequences, and so on), you use sql as a data manipulation language (dml). with dml, you execute sql operations that manipulate and retrieve data. the manipulation operations include insertion, update, and deletion. you retrieve data by executing queries with restriction, projection, and join operations (including the cartesian product). for efficient reporting, you use sql to group, order, and aggregate data in arbitrary ways. you can even nest sql statements inside each other; this technique is called subselecting. you have probably used sql for many years and are familiar with the basic operations and statements written in this language. still, we know from our own experience that sql is sometimes hard to remember and that some terms vary in usage. to understand this book, we have to use the same terms and concepts; so, we advise you to read appendix a if any of the terms weve mentioned are new or unclear.sql knowledge is mandatory for sound java database application development.if you need more material, get a copy of the excellent book sql tuning by dan towalso read an introduction to database systems date 2004 for the theory, concepts, and ideals of (relational) database systems. although the relational database is one part of orm, the other part, of course, consists of the objects in your java application that need to be persisted to the database using sql.using sql in javawhen you work with an sql database in a java application, the java code issues sql statements to the database via the java database connectivity (jdbc) api. the sql itself might have been written by hand and embedded in the java code, or it might have been generated on the fly by java code. you use the jdbc api to bind arguments to query parameters, initiate execution of the query, scroll through the query result table, retrieve values from the result set, and so on. these are lowlevel data access tasks; as application developers, were more interested in the business problem that requires this data access. it isnt clear that we should be concerning ourselves with such tedious, mechanical details.what wed really like to be able to do is write code that saves and retrieves complex objectsthe instances of our classesto and from the database, relieving us of this low-level drudgery.since the data access tasks are often so tedious, we have to ask: are the relational data model and (especially) sql the right choices for persistence in objectoriented applications? we answer this question immediately: yes! there are many reasons why sql databases dominate the computing industry. relational database management systems are the only proven data management technology and are almost always a requirement in any java project.however, for the last 15 years, developers have spoken of a paradigm mismatch.this mismatch explains why so much effort is expended on persistence-related concerns in every enterprise project. the paradigms referred to are object modeling and relational modeling, or perhaps object-oriented programming and sql. lets begin our exploration of the mismatch problem by asking what persistence means in the context of object-oriented application development. first well widen the simplistic definition of persistence stated at the beginning of this section to a broader, more mature understanding of what is involved in maintaining and using persistent data.persistence in object-oriented applicationsin an object-oriented application, persistence allows an object to outlive the process that created it. the state of the object may be stored to disk and an object with the same state re-created at some point in the future.this application isnt limited to single objectsentire graphs of interconnected objects may be made persistent and later re-created in a new process. most objects arent persistent; a transient object has a limited lifetime that is bounded by the life of the process that instantiated it. almost all java applications contain a mix of persistent and transient objects; hence we need a subsystem that manages our persistent data.modern relational databases provide a structured representation of persistent data, enabling sorting, searching, and aggregation of data. database management systems are responsible for managing concurrency and data integrity; theyreresponsible for sharing data between multiple users and multiple applications. a database management system also provides data-level security. when we discuss persistence in this book, were thinking of all these things: storage, organization, and retrieval of structured data concurrency and data integrity data sharingin particular, were thinking of these problems in the context of an object-oriented application that uses a domain model.an application with a domain model doesnt work directly with the tabular representation of the business entities; the application has its own, object-oriented model of the business entities. if the database has item and bid tables, the java application defines item and bid classes.then, instead of directly working with the rows and columns of an sql result set, the business logic interacts with this object-oriented domain model and its runtime realization as a graph of interconnected objects. the business logic is never executed in the database (as an sql stored procedure), its implemented in java. this allows business logic to make use of sophisticated object-oriented concepts such as inheritance and polymorphism. for example, we could use wellknown design patterns such as strategy, mediator, and composite gof 1995, all of which depend on polymorphic method calls. now a caveat: not all java applications are designed this way, nor should they be. jdbc rowset (sun jcp, jsr 114) makes crud operations even easier. working with a tabular , the domain model helps to improve code reuse and maintainability significantly. we focus on applications with a domain model in this book, since hibernate and orm in general are most relevant to this kind of application. if we consider sql and relational databases again, we finally observe the mismatch between the two paradigms. sql operations such as projection and join always result in a tabular representation of the resulting data. this is quite different than the graph of interconnected objects used to execute the business logic in a java application! these are fundamentally different models, not just different ways of visualizing the same model. with this realization, we can begin to see the problemssome well understood and some less well understoodthat must be solved by an application that combines both data representations: an object-oriented domain model and a persistentrelational model. lets take a closer look.理解对象-关系持续性我们工作的每个软件项目工程中,管理持续性数据的方法已经成为一项关键的设计决定。对于java应用,持续性数据并不是一个新的或不寻常的需求,你也许曾经期望能够在许多相似的,已被很好构建的持续性解决方案中简单地进行选择。考虑一下web应用框架(jakarta struts 对 webwork),gui组件框架(swing 对 swt),或模版工具(jsp 对 velocity)。每一种相互竞争的解决方案都有其优缺点,但它们至少都共享了相同的范围与总体的方法。不幸的是,这还不是持续性技术的情形,对持续性技术相同的问题有许多不同的混乱的解决方案。在过去的几年里,持续性已经成为java社区里一个争论的热点话题。对这个问题的范围许多开发者的意见甚至还不一致。持续性还是一个问题吗?它早已被关系技术与其扩展例如存储过程解决了。或者它是一个更一般的问题,必须使用特殊的java组件模型例如ejb实体bean来处理?甚至sql和jdbc中最基本的crud(create, read, update, delete)操作也需要进行手工编码,还是让这些工作自动化?如果每一种数据库管理系统都有它自己的方言,我们如何达到可移植性?我们应该完全放弃sql并采用一种新的数据库技术,例如面向对象数据库系统吗?争论仍在继续,但是最近一种称作对象-关系映射(orm)的解决方案逐渐地被接受。hibernate就是这样一种开源的orm实现。hibernate是一个雄心勃勃的项目,它的目标是成为java中管理持续性数据问题的一种完整的解决方案。它协调应用与关系数据库的交互,让开发者解放出来专注于手中的业务问题。hibernate是一种非强迫性的解决方案。我们的意思是指在写业务逻辑与持续性类时,你不会被要求遵循许多hibernate特定的规则和设计模式。这样,hibernate就可以与大多数新的和现有的应用平稳地集成,而不需要对应用的其余部分作破坏性的改动。本篇文章是关于hibernate的。我们包含了基本与高级的特征,并且描述了许多使用hibernate开发新应用时的推荐方式。通常这些推荐并不特定于hibernate有时它们可能是我们关于使用持续性数据工作时处理事情的最佳方式的一些想法,只不过在hibernate的环境中进行了介绍。然而,在我们可以开始使用hibernate之前,你需要理解对象持续性和对象-关系映射的核心问题。本章解释了为什么像hibernate这样的工具是必需的。首先,我们定义了在面向对象的应用环境中持续性数据的管理,并且讨论了sql,jdbc和java的关系,hibernate就是在这些基础的技术与标准之上构建的。然后我们讨论了所谓的对象-关系范例不匹配的问题和使用关系数据库进行面向对象的软件开发中所遇到的一些一般性的问题。随着这个问题列表的增长,我们需要一些工具与模式来最小化我们用在与持续性有关的代码上的时间就变得很明显了。在我们查看了可选的工具和持续性机制后,你会发现orm在许多情况下可能是最好的解决方案。我们关于orm的优缺点的讨论给了你一个完整的背景,在你为自己的项目选择持续性解决方案时可以作出最好的决定。什么是持续性?几乎所有的应用都需要持续性数据。持续性在应用开发中是一个基本的概念。如果当主机停电时一个信息系统没有保存用户输入的数据,这样的系统几乎没有实际的用途。当我们讨论java中的持续性时,我们通常是指使用sql存储在关系数据库中的数据。我们从简单地查看一下这项技术和我们如何在java中使用它开始。具有了这些知识之后,我们继续关于持续性的讨论以及如何在面向对象的应用中实现它。关系数据库你,像许多其他的开发者,很可能在使用一个关系数据库进行工作。实际上,我们中的大多数每天都在使用关系数据库。关系技术是一个已知数。仅此一点就是许多组织选择它的一个充分的理由。但仅仅这样说就有点欠考虑了。关系数据库如此不易改变不是因为偶然的原因而是因为它们那令人难以置信的灵活与健壮的数据管理方法。关系数据库管理系统既不特定于java,也不特定于特殊的应用。关系技术提供了一种在不同的应用或者相同应用的不同技术(例如事务工具与报表工具)之间共享数据的方式。关系技术是多种不同的系统与技术平台之间的一个共同特征。因此,关系数据模型通常是业务实体共同的企业级表示。关系数据库管理系统具有基于sql的应用编程接口,因此我们称今天的关系数据库产品为sql数据库管理系统,或者当我们讨论特定系统时,称之为sql数据库。理解sql为了有效地使用hibernate,对关系模型和sql扎实的理解是前提条件。你需要用你的sql知识来调节你的hibernate应用的性能。hibernate会自动化许多重复的编码任务,如果你想利用现代sql数据库的全部能力,你的持续性技术的知识必须扩充至超过hibernate本身。记住基本目标是健壮地有效地管理持续性数据。让我们回顾一些本书中用到的sql术语。你使用sql作为数据定义语言(ddl)通过create与alter命令来创建数据库模式。创建了表(索引,序列等等)之后,你又将sql作为数据处理语言(dml)来使用。使用dml,你执行sql操作来处理与取出数据。处理操作包括插入,更新和删除。你使用约束,投射,和连接操作(包括笛卡尔积)执行查询来取出数据。为了有效地生成报表,你以任意的方式使用sql来分组,排序和合计数据。你甚至可以相互嵌套sql命令,这项技术被称作子查询。你也许已经使用了多年的sql并且非常熟悉用它编写的基本操作和命令。尽管如此,我们的经验还是告诉我们sql有时难于记忆并且有些术语有不同的用法。为了理解本书,我们不得不使用相同的术语与概念;因此,如果我们提到的任何术语是新出现的或者是不清楚的。 为了进行健全的java数据库应用开发,sql知识是强制的。如果你需要更多的资料,找一本dan tow的优秀著作sql tuning。同时读一下an introduction to database systems,学习一些(关系)数据库系统的理论,概念和思想。关系数据库是orm的一部分,当然另一部分由你的java应用中的对象构成,它们需要使用sql被持续化到数据库中。在java中使用sql当你在java应用中使用sql工作时,java代码通过java数据库连接(jdb

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论