什么是对象/关系不匹配 [英] What is Object/Relational mismatch

查看:165
本文介绍了什么是对象/关系不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,正在阅读有关对象关系映射的信息.我在此链接上找到了对象/关系不匹配"一词休眠

I am a newbie to java and was reading about Object Relational Mapping. I found a term Object/Relational mismatch on this link Hibernate

任何人都可以用Java解释什么是对象/关系不匹配. 我还从 haacked.com 中了解了此信息,但没有正确地获取它.用示例进行说明将是可理解的.

Can anyone explain what is Object/Relational mismatch in terms of Java. I also read about it from haacked.com but could not get it properly.Explanation with example would be appreciable.

推荐答案

Hibernate是一种ORM(对象关系映射)工具.其主要目的是将概念从面向对象的编程(例如类,继承和字段)转换为关系数据库中使用的概念(例如表,行和列).

Hibernate is an ORM (Object-Relational Mapping) tool. Its primary purpose is to translate concepts from object-oriented programming, such as classes, inheritance and fields, to concepts used in relational databases, such as tables, rows and columns.

例如,一个类对应于一个数据库表,一个对象(一个类的实例)对应于一个数据库行,而一个字段则对应于一个数据库列.

For example, a class corresponds to a database table, an object (instance of a class) corresponds to a database row, and a field corresponds to a database column.

术语对象/关系不匹配"是指以下事实:没有明确的方法将所有概念从面向对象的编程转换为关系数据库的概念,反之亦然. Hibernate尝试解决此问题.

The term "object/relational mismatch" refers to the fact that there is not a clear way to translate all the concepts from object-oriented programming to relational database concepts and vice versa. Hibernate attempts to solve this problem.

例如,如何将继承转换为关系数据库概念?关系数据库中没有继承的东西,因此必须发明某种方式在数据库中表示继承. Hibernate有不同的方法来执行此操作,例如,为类层次结构使用一个表,并使用一个鉴别符列确定行映射到哪个子类,或者通过每个子类都有一个表.

For example, how do you translate inheritance to relational database concepts? There's no such thing as inheritance in a relational database, so some way has to be invented to represent this in the database. Hibernate has different ways to do this, for example by having one table for the class hierarchy with a discriminator column to determine to which subclass a row maps, or by having a table per subclass.

同样,关系数据库中存在一些无法轻易转换为面向对象编程概念的概念.

Likewise, there are concepts that exist in a relational database that cannot easily be translated to object oriented programming concepts.

这篇关于什么是对象/关系不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆