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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值