`

What is and Why O/R Mapping?

阅读更多

O/R Mapping 是 Object Relational Mapping(对象关系映射)的缩写是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术。通俗点讲,就是将对象与关系数据库绑定,用对象来表示关系数据。

 

 

用O/R Mapping带来的好处:

 

1.在具体的操作数据库的时候,就不需要再去和复杂的SQL语句打交道,只要像操作对象就可以了,   O/R   Mapping工具会自动地将对象的操作转换为SQL语句操作。
这样我们就只需要关注业务逻辑中的对象架构,而不是底层的重复性的数据库SQL和JDBC代码。  
在插入多个对象,特别是插入多个关联对象的情况下,更可以看到O/R   Mapping的优势。在Liberator   JDO框架中,支持Persistence   By   Reachability,在保存对象的时候,可以将该对象所引用的所有对象自动都保存到相应的数据表中,而不需要每个对象都做保存的操作。  

如果采用传统的手工SQL,   JDBC方式编码,代码量可以多出近5倍。在算上测试节省的时间,可以件采用O/R   Mapping技术可以极大的提高开发效率和开发时间,同时开发质量也更容易保证。

 

2.   提高学习和开发效率,极大的降低开发成本。
使用ORM可以大大降低学习和开发成本,现代技术的发展,使得我们需要不断学习。我们不仅要学习面向对象、UML、设计模式等知识,而且还需要学习SQL,   JDBC,甚至是各种数据库(   DB2,   Oracle,   SQL   Server等)的知识。而在实际的开发中,真正对客户有价值的是其独特的业务功能,而现在的现状是我们花费了大量的时间在编写数据访问,包括后期的Bug查找,维护等也会花费相当多的时间在数据处理上。这就是说,我们在实际的开发中很多的时间都被浪费在根本不创造价值的非业务事件上了。  

在使用ORM之后,我们将不需要再浪费太多的时间在   SQL语句,   JDBC上的开发和测试上。ORM框架已经把底层的数据库操作转变成了我们熟悉的对象操作,我们将只需要了解面向对象开发就可以实现数据库应用程序的开发。  

 

3   简化代码,减少BUG数量。
通过建立ORM框架,能够大量减少程序开发代码,开发数据层就比较简单,大大减少了出错机会。  

 

4.简化测试。只需测试业务逻辑的类和行为,避免重复的JDBC测试  

 

5.   提高性能   对象级缓存(   缓存对象及其关系   )可以避免不必要的数据库存取,极大的提高数据读写的性能。我们也可以节省用于系统调优的时间和工作量。  

 

6.   隔离数据源,可以很方便的转换数据库   ORM可以将业务层与实际的数据存储隔开,开发人员不需要关心实际存储的方式,如果我们需要把SQL   Server数据库换成ORACLE数据库,只需要修改配置文件就可,业务逻辑代码完全不需要修改。  

 

分享到:
评论

相关推荐

    一个跨平台的CString源码

    // AUTHOR: Joe O'Leary (with outside help noted in comments) // // If you find any bugs in this code, please let me know: // // jmoleary@earthlink.net // http://www.joeo.net/stdstring.htm (a ...

    Entity Framework Code First Succinctly(Syncfusion,2014)

    Since Entity Framework was first included in Visual Studio 2008 and the .NET Framework 3.5 SP1, and certainly object/relational mapping existed long before that, then why is there all this hype around...

    Cplusplus.CLI.Primer.For.NET.Development

    Discover C++/CLI and why is it used in .NET programming Work with types, primitive types, object creation, and managed and abstract classes Use abstract classes in C++/CLI Harness the power of ...

    developing android application with adobe air.part4.rar

    What Is Multitouch and Gesture? The Multitouch Class The GestureEvent Class The TouchEvent Class The GestureWorks Library Designing for Touch Conclusion Chapter 8 : Accelerometer What Is a Motion ...

    developing android application with adobe air.part2.rar

    What Is Multitouch and Gesture? The Multitouch Class The GestureEvent Class The TouchEvent Class The GestureWorks Library Designing for Touch Conclusion Chapter 8 : Accelerometer What Is a Motion ...

    developing android application with adobe air.part3.rar

    What Is Multitouch and Gesture? The Multitouch Class The GestureEvent Class The TouchEvent Class The GestureWorks Library Designing for Touch Conclusion Chapter 8 : Accelerometer What Is a Motion ...

    developing android application with adobe air.part1

    What Is Multitouch and Gesture? The Multitouch Class The GestureEvent Class The TouchEvent Class The GestureWorks Library Designing for Touch Conclusion Chapter 8 : Accelerometer What Is a Motion ...

    UE(官方下载)

    Did you know that you can not only change what is on UltraEdit's toolbars, you can also change the icon used, as well as create your own custom toolbars and tools? File tabs Understand how file tabs ...

    微软内部资料-SQL性能优化2

     List at least two memory myths and why they are not true. Recommended Reading  SQL Server 7.0 Performance Tuning Technical Reference, Microsoft Press  Windows 2000 Resource Kit companion CD-...

    Metal.编程向导英文版.and.Reference.via.Swift.pdf.zip

    Chapter 1: What Is Metal? 3 History of Graphics APIs 4 Metal: The New Way to Do Graphics on Apple Platforms 6 Metal in Context: How Metal Complements and Supports Other Platform Frameworks 10 Summary ...

    Unity 5.x Shaders and Effects Cookbook (2016)

    Book Description: Since their introduction ...Discover what goes into the structure of Shaders and why lighting works the way it does Master the math and algorithms behind the most used lighting models

    Scala.Functional.Programming.Patterns.178398

    This book begins with the rationale behind patterns to help you understand where and why each pattern is applied. You will discover what tail recursion brings to your table and will get an ...

    一本android的好书beginning android 2 和 源码

    ■Chapter 33: Mapping with MapView and MapActivity Terms, Not of Endearment Piling On The Bare Bones Exercising Your Control Zoom Center Rugged Terrain Layers upon Layers Overlay Classes Drawing ...

    Incremental.Software.Architecture

    Chapter 2: What Is a Failing Enterprise System? Is It Management's Fault? Chapter 3: Technological System-Level Failures Part Two: End-State Architecture Discovery and Analysis Chapter 4: System ...

    Inside.Microsoft.NET.IL.Assembler

    Why This Book Was Written To tell the truth, I don't think I had much choice in this matter. Let me explain. With Microsoft .NET technology taking the world by storm, with more and more information ...

    ComponentOne Studio for Silverlight 2012 v3 1/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne Studio for Silverlight 2012 v3 3/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne Studio for Silverlight 2012 v3 2/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne 2012 V2 Studio for Silverlight 3/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne 2012 V2 Studio for Silverlight 2/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

Global site tag (gtag.js) - Google Analytics