直到现在我对映射关系都不是非常了解,希望以后有个更深的了解,今天只是把这七种关系记下来.
One-to-one unidirectional
The relationship between a customer and an address. You clearly want to be able to look up a customer's address, but you probably don't care about looking up an address's customer.
One-to-one bidirectional
The relationship between a customer and a credit card number. Given a customer, you obviously want to be able to look up his credit card number. Given a credit card number, it is also conceivable that you would want to look up the customer who owns the credit card.
One-to-many unidirectional
The relationship between a customer and a phone number. A customer can have many phone numbers (business, home, cell, etc.). You might need to look up a customer's phone number, but you probably wouldn't use one of those numbers to look up the customer.
One-to-many bidirectional
The relationship between a cruise and a reservation. Given a reservation, you want to be able to look up the cruise for which the reservation was made. And given a particular cruise, you want to be able to look up all reservations. (Note that a many-to-one bidirectional relationship is just another perspective on the same concept.)
Many-to-one unidirectional
The relationship between a cruise and a ship. You want to be able to look up the ship that will be used for a particular cruise, and many cruises share the same ship, though at different times. It's less useful to look up the ship to see which cruises are associated with it, although if you want this capability, you can implement a many-to-one bidirectional relationship.
Many-to-many unidirectional
The relationship between a reservation and a cabin. It's possible to make a reservation for multiple cabins, and you clearly want to be able to look up the cabin assigned to a reservation. However, you're not likely to want to look up the reservation associated with a particular cabin. (If you think you need to do so, implement it as a bidirectional relationship.)
Many-to-many bidirectional
The relationship between a cruise and a customer. A customer can make reservations on many cruises, and each cruise has many customers. You want to be able to look up both the cruises on which a customer has a booking and the customers that will be going on any given cruise.
摘自
Enterprise JavaBeans, 3.0 |
分享到:
相关推荐
本压缩包文件“Hibernate映射解析 七种映射关系 后端 - Java.zip”中详细介绍了Hibernate的核心概念——映射关系。以下是关于Hibernate映射关系的详细解释: 1. **一对一映射** (One-to-One Mapping) 在一对一映射...
便于同学们更好的学习hibernate,其中包含了hibernate的七种映射管、关系
下面我们将详细探讨标题中提到的七种映射关系: 1. **单向一对一**: 在这种关系中,一个实体只有一个对应实体与之关联,且只在一个方向上有引用。通常通过`@OneToOne`注解来实现,可以设置`mappedBy`属性来指定...
例如,可以总结出一套针对特定场景的最佳实践,如如何处理具有大量属性的类的映射问题。 #### 十一、结论 对象/关系映射是一项复杂但至关重要的任务,对于确保软件系统的可扩展性和性能有着重要意义。通过理解不同...
在Java开发中,Hibernate是一个非常重要的对象关系映射(ORM)框架,它允许开发者使用面向对象的方式来操作数据库,极大地简化了数据库操作。本教程将详细讲解Hibernate中的关联关系映射配置,帮助你理解和掌握如何...
在Java世界中,Hibernate是一个非常流行的ORM(对象关系映射)框架,它允许开发者将数据库操作转换为面向对象的方式,从而简化了数据访问层的编程。"hibernate关联关系映射"是Hibernate的核心概念之一,它定义了如何...
**O/R Mapping**(Object/Relational Mapping),即对象关系映射,是一种编程技术,用于将对象模型与关系型数据库模型进行相互转换。在软件开发中,尤其是在使用关系型数据库的应用程序中,这种技术非常常见。它允许...
Hibernate关系映射是Java开发中一种重要的对象关系映射(ORM)技术,它允许开发者用面向对象的方式处理数据库操作,极大地提高了开发效率。本篇将深入探讨Hibernate关系映射的核心概念、配置和常见实践,以帮助你更...
最近查的涵盖以下号段 ,映射规则为前七位映射 电信 = ['133', '149', '153', '173', '177', '180', '181', '189', '199'] 联通 = ['130', '131', '132', '145', '146', '155', '156', '166', '171', '175', '176', ...
质量管理新七种工具是日本科学技术联盟于1972年组织的一些专家运用运筹学或系统工程的原理和方法,经过多年的研究和现场实践后于1979年正式提出用于质量管理的。这七种新工具是对“老七种工具”的补充和丰富,具有...
映射方式包括外键约束和主键共享两种,外键约束是在一方的实体类中添加对方的引用,主键共享是双方共享同一个主键。 **三、Hibernate的一对多关系映射** 在一对多关系中,一个实体可以对应多个其他实体,用`@...
在Java开发领域,对象关系映射(ORM)是一种将数据库中的数据与程序中的对象进行关联的技术,它极大地简化了数据操作。Hibernate作为一款流行的ORM框架,使得开发者无需关注底层SQL语句,就能方便地实现数据的增删改...
在讨论 CRM 与 BOSS 的关系时,我们需要了解两个系统之间的交互关系和数据映射关系。下面我们将详细介绍 CRM 与 BOSS 之间的关系。 一、模型的映射关系 在 CRM 与 BOSS 系统之间,我们需要建立模型的映射关系,以...
#### 七、关联映射 关联映射是对象关系映射中另一重要概念,主要包括: 1. **单向关联**:实体类之间存在依赖关系,但仅有一方维护关联信息。 2. **多对一关联**:一个实体可能属于另一个实体的多个实例。 3. **一...
质量管理学中的新七种工具是1972年由日本科学技术联盟下属的“质量管理方法研究会”提出并逐渐发展起来的,旨在提供更为高效的问题解决和质量管理策略。这七种工具包括关系图、系统图、KJ法、矩阵图、矩阵数据分析法...