基于web的学生公寓管理系统的设计与实现毕业设计(论文)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

大连交通大学信息工程学院

毕业设计(论文)任务书

题目基于web的学生公寓管理系统的设计与实现

大连交通大学信息工程学院

毕业设计(论文)进度计划与考核表

指导教师签字:年月日注:“计划完成内容”由学生本人认真填写,其它由指导教师考核时填写。

大连交通大学信息工程学院

毕业设计(论文)外文翻译

学生姓名方广志专业班级软件工程08-3班

指导教师阎树昕王立娟职称高工讲师

所在单位信息科学系软件工程教研室

教研室主任刘瑞杰

完成日期 2012 年 4 月 13 日

Hibernate In Action

Retrieving objects

Retrieving persistent objects from the database is one of the most interesting (andcomplex)

parts of working with Hibernate. Hibernate provides the following waysto get objects out of the database:

■ Navigating the object graph, starting from an already loaded object, byaccessing the associated objects through property accessor methods such as a User.getAddress().getCity(). Hibernate will automatically load (or preload)nodes of the graph while you navigate the graph if the Session is open.

■ Retrieving by identifier, which is the most convenient and performant method when the uniqueidentifier value of an object is known.

■ Using the Hibernate Query Language (HQL), which is a full object-orientedquerylanguage.

■ Using the, Hibernate Criteria API, which provides a type-safe and objectoriented way to perform queries without the need for string manipulation.This facility includes queries based on an example object.

■ Using native SQL queries, where Hibernate takes care of mapping the JDBC result sets to graphs of persistent objects.In your Hibernate applications, you’ll use a combination of these techniques.Each retrieval method may use a different fetching strategy—that is, a strategy that defines what part of the persistent object graph should be retrieved. The goal is to find the best retrieval method and fetching strategy for every use case in your application while at the same time minimizing the number of SQL queries for best performance.

We won’t discuss each retrieval method in much detail in this section; instead we’ll focus on the basic

fetching strategies and how to tune Hibernate mapping files for best default fetching for all methods. Before we look at the fetching strategies, we’ll give an overview of the retrieval methods. (We mention the Hibernate caching system but fully explore it in the next chapter.) Let’s start with the simplest case, retrieval of an object by giving its identifier value (navigating the object graph should self-explanatory). You saw a simple retrieval by identifier earlier in this chapter, but there is more to know about it.

Retrieving objects by identifier

The following Hibernate code snippet retrieves a User object from the database:

User user = (User) session.get(User.class, userID);The get() method is special because the identifier uniquely identifies a single;instance of a class. Hence it’s common for applications to use the identifier as aconvenient handle to a persistent object. Retrieval by identifier can use the cachewhen retrieving an object, avoiding a database hit if the object is already cached.

Hibernate also provides a load() method:User user = (User) session.load(User.class, userID);

The load() method is older; get() was added to Hibernate’s API due to userrequest. The difference is trivial:

■ If loa d() can’t find the object in the cache or database, an exception isthrown. The load()

相关文档
最新文档