2008-04-03
JavaPersistenceWithHibernate读书笔记(4)
关键字: 1.2.4 problems relating to associations
1.2.4 Problems relating to associations
在我们的E-Co实例中的Domain model里,实例对象的关系是用associations表示的,这样User Address和BillingDetials就可以关联起来.不过,BillingDetails与Address不同的是,在BD中这个类有自己表存放数据.
实例对象间的关联及其管理是ORM中的核心内容.
OO中,关联关系是以对象间的引用来表达的,而在SQL世界里,数据的关联是用外键和键值的复制来表示的.关联关系的这两种表示有很大的不同:
Java World:对象间的引用有天生的方向性.
SQL World: 而靠外键方式获得的关联却没有任何的方向性.
The challenge is to bridge a completely open data model, which is independent of the application that works with the data, to an application-dependent navigational model, a constrained view of the associations needed by this particular application.
在Java里,我们也不能从单向关联里看出任何与关联的数量相关的信息,Java里也可以很轻易地表达出多对多的关联关系.
而在SQL世界里,表间的关联关系总是一对多或一对一的,这样的数量信息我们也可以很容易的从外键的定义上看的出来.
The following is a foreign key declaration on the BILLING_DETAILS table for a one-to-many association (or, if read in the other direction, a many-to-one association): (现在对这个"一"的理解还是不够,也分不清哪个是"一"哪个是"多" )
USER_ID bigint foreign key references USERS
These are one-to-one associations:
USER_ID bigint unique foreign key references USERS
BILLING_DETAILS_ID bigint primary key foreign key references USERS
而对于多对多的关联关系,我们只能通过一个中间表来表达了.
We discuss association and collection mappings in great detail in chapters 6 and 7.
So far, the issues we’ve considered are mainly structural. We can see them by considering a purely static view of the system. Perhaps the most difficult problem in object persistence is a dynamic problem. It concerns associations, and we’ve already hinted at it when we drew a distinction between object network navigation and table joins in section 1.1.4, “Persistence in object-oriented applications.” Let’s explore this significant mismatch problem in more depth.
在我们的E-Co实例中的Domain model里,实例对象的关系是用associations表示的,这样User Address和BillingDetials就可以关联起来.不过,BillingDetails与Address不同的是,在BD中这个类有自己表存放数据.
实例对象间的关联及其管理是ORM中的核心内容.
OO中,关联关系是以对象间的引用来表达的,而在SQL世界里,数据的关联是用外键和键值的复制来表示的.关联关系的这两种表示有很大的不同:
Java World:对象间的引用有天生的方向性.
SQL World: 而靠外键方式获得的关联却没有任何的方向性.
The challenge is to bridge a completely open data model, which is independent of the application that works with the data, to an application-dependent navigational model, a constrained view of the associations needed by this particular application.
在Java里,我们也不能从单向关联里看出任何与关联的数量相关的信息,Java里也可以很轻易地表达出多对多的关联关系.
而在SQL世界里,表间的关联关系总是一对多或一对一的,这样的数量信息我们也可以很容易的从外键的定义上看的出来.
The following is a foreign key declaration on the BILLING_DETAILS table for a one-to-many association (or, if read in the other direction, a many-to-one association): (现在对这个"一"的理解还是不够,也分不清哪个是"一"哪个是"多" )
USER_ID bigint foreign key references USERS
These are one-to-one associations:
USER_ID bigint unique foreign key references USERS
BILLING_DETAILS_ID bigint primary key foreign key references USERS
而对于多对多的关联关系,我们只能通过一个中间表来表达了.
We discuss association and collection mappings in great detail in chapters 6 and 7.
So far, the issues we’ve considered are mainly structural. We can see them by considering a purely static view of the system. Perhaps the most difficult problem in object persistence is a dynamic problem. It concerns associations, and we’ve already hinted at it when we drew a distinction between object network navigation and table joins in section 1.1.4, “Persistence in object-oriented applications.” Let’s explore this significant mismatch problem in more depth.
- 10:41
- 浏览 (749)
- 评论 (0)
- 分类: 我的读书笔记
- 发布在 Database圈子 圈子
- 相关推荐
发表评论
- 浏览: 29429 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
链接
最新评论
-
对浏览器中的context menu ...
Drag dropper
-- by whqida -
Spring中的load-time weav ...
没啥,有些class不在spring的管理之中,通过 load-time wea ...
-- by ray_linn -
对浏览器中的context menu ...
别搞笑了, 这是浏览器的 Context Menu? 这只不过是响应了鼠标右击事 ...
-- by fcoffee -
IE tab在Firefox里开发时 ...
firebug只能用于ff, 并不能用于ff下的ietab, 原因显而易见.如果 ...
-- by fcoffee -
IE tab在Firefox里开发时 ...
还网告知 该如何操作呢 我还是要到ie下再调试啊
-- by jianfeng008cn






评论排行榜