`

Why ORM?

阅读更多


下面这段话是从<Spring In Action>这本书里摘过来的,这是作者是从JDBC过渡到Hibenate时对ORM的一段介绍.现在Log进这里,借用星爷的一句话:谨以此来表达鄙人对这两个框架及其开发团队的敬意.

When we were kids, riding a bike was fun, wasn’t it? We would ride to school in the mornings. When school let out, we would cruise to our best friend’s house. When it got late and our parents were yelling at us for staying out past dark, we would peddle home for the night. Gee, those days were fun.
 Then we grew up and we needed more than a bike. Sometimes we have to travel quite a distance to work. Groceries have to be hauled, and ours kids need to get to soccer practice. And if you live in Texas, air-conditioning is a must! Our needs have simply outgrown our bike.
 JDBC is the bike of the persistence world. It is great for what it does, and for some jobs it works just fine. But as our applications become more complex, so do our persistence requirements. We need to be able to map object properties to database columns and have our statements and queries created for us, freeing us from typing an endless string of question marks. We also need features that are more sophisticated:

    ■ Lazy loading—As our object graphs become more complex, we sometimes don’t want to fetch entire relationships immediately. To use a typical example, suppose we are selecting a collection of urchaseOrder objects, and each of these objects contains a collection of LineItem objects. If we are only interested in PurchaseOrder attributes, it makes no sense to grab the LineItem data. This could be quite expensive. Lazy loading allows us to grab data only as it is needed.
    ■ Eager fetching—This is the opposite of lazy loading. Eager fetching allows    you to grab an entire object graph in one query. In the cases where we know    that we need a PurchaseOrder object and its associated LineItems, eager    fetching lets us get this from the database in one operation, saving us from costly round-trips.
    ■ Cascading—Sometimes changes to a database table should result in changes    to other tables as well. Going back to our purchase order example, when an    Order object is deleted, we also want to delete the associated  LineItems    from the database.
1
0
分享到:
评论

相关推荐

    Java的ORM框架ComnonDAO.zip

    Why CommonDAO? 以简洁为主,其前身是以spring jdbc为基础的扩展,为的是提高可用性,当时在spring jdbc的基础上,参考Hibernate, iBatis,目的就是简洁,高效。 之后,随着spring jdbc的发展,spring 的orm走向...

    Spring学习笔记之一“why spring”

    Spring还包含了数据访问和集成层,如Spring JDBC和ORM模块,支持与各种数据库系统(如MySQL、Oracle等)的交互,以及与Hibernate、JPA等ORM框架的集成。这简化了数据库操作,减少了代码重复。 在Web开发方面,...

    开源项目-go-pg-pg#why-go-pg.zip

    开源项目-go-pg-pg#why-go-pg.zip,ORM for Postgres with SQL joins that are 2x-10x faster than GORM (sharding included)

    gormjqdt:用于gorm的Golang jQuery数据表服务器端分页

    该模块正在使用并且用于gorm(golang ORM模块),在使用该模块之前,请确保已安装gorm。 go get -u github.com/sutejoramadhan/gormjqdt :eyes: 概述 处理通用功能jQuery Datatable,例如对单列或多列进行排序,...

    1.spring_whyspring

    标题 "1.spring_whyspring" 暗示了我们即将探讨的是关于Spring框架的一些核心概念和它为何在IT行业中如此重要。这篇博文链接虽然没有提供具体的内容,但我们可以通过标签"源码"和"工具"来推测文章可能涉及Spring框架...

    Why I chose mongodb

    这个时期标志着从传统数据库向现代Java应用的转变,但依然存在数据库抽象层通过ORM(对象关系映射)实现的问题。 4. MongoDB的优势:文章提到选择MongoDB来构建guardian.co.uk网站,暗示了其在灵活性、模型的适应性...

    一款基于python语言的Web开发框架+源代码+文档说明

    ##Why Python? 我曾经使用过Java、PHP、Ruby和Python来开发Web应用,至于为什么使用Python作为XWEB的语言,其实最主要的原因: 1. Ruby不再需要新的WEB开发框架,Rails统治了一切。 2. PHP没有多线程,对于后台...

    sod:PDF.NET 的追求:代码的精简,开发、维护的简单与极致的运行效率!

    菜鸟:“怎么使用EF(Entity Framework)框架啊?遇到麻烦了,救命!”Beginner:"How to use Entity ...EF框架或大部分ORM框架的缺点就是SOD框架的优点,它拥有超过15年的项目应用历史,为你而生!The disadvantag

    Struts+Hibernate学习资料

    2. **Why?** 存储在数据库中可以简化备份过程,避免依赖于文件系统的同步,同时减少与特定用户文件的直接关联。 3. **How?** 使用Hibernate,通过BLOB字段操作二进制数据。Hibernate提供方便的方法来存取和管理...

    基于Symfony框架下的快速企业级应用开发.pdf

    同时,还提供了ORM(对象关系映射)来处理数据库操作。 - **Plugin**:Symfony拥有一个活跃的社区,提供了大量的现成插件。开发者既可以使用现有的插件,也可以贡献自己的插件。 #### Symfony的抽象类示例 - `...

    Hello! Python.pdf

    Django通过其内置的ORM(对象关系映射)、模板系统以及强大的安全性特性,简化了Web应用的开发过程。本章将介绍如何使用Django创建RESTful API、处理用户认证以及实现前后端分离的架构。 ### 9. 游戏开发 第九章...

Global site tag (gtag.js) - Google Analytics