`

JavaPersistenceWithHibernate读书笔记(1)

阅读更多
Part 1: Getting started with Hibernate and EJB3.0

In part1, we show you why object persistence is such a complex topic and what soluctions you can apply in practice.
    chapter1: O/R paradigm mismatch and several strategies to deal with it.
    chapter2: a guide step-by-step through a tutorial with Hibernate, Java Persistence and EJB 3.0.
    chapter3: learn how to design and implement complex business domain models in Java,and mapping metadata.

-->to understand why you need ORM,and how Hibernate,JPA,EJB3.0 work in practice.

Chaper1: Understanding OR persistence

Detate continues, but a solution called ORM now has wide acceptance.It mediates the application's interaction with a relational database,leaving the developer free to concentrate on teh business problem at hand.

Often,these recommendations won't even be specific to Hibernate.Sometimes they will be our ideas about the best way to do things when working with persistent data,explained in the context of Hibernate.

BEFORE WE CAN GET STARTED WITH HIBERNATE, HOWEVER, YOU NEED TO UNDERSTAND THE CORE PROBLEMS OF OBJECT PERSISTENCE AND ORM.

FIRST: we difine persistent data management(RDBMS只是这个PDM一种,用OO语言来描述就是说RDBMS是PDM interfacer的一种实现) in the context of object-oriented applications and discuss the relationship of SQL, JDBC,and Java,the underlying technologies and standards that Hibernate is built on.

THEN: discuss the so-called OR paradigm mismatch.These problem make it clear that we need tools and patterns to minimize the time we have to spend on the persistence-related code of our applications.

1.1 What is persistence?
    If an information system didn't preserve data when it was powered off,the system would be of little practical use.When we talk about persistence in Java,we're normally talking about storing data in a relational database using SQL.

1.1.1 Relational databases
    .............
    But to say only this is to pay less respect than is due.
1.1.2 Understanding SQL
    to tune the performace of ...
    extend beyond Hibernate itself if you want to take advantage of the full power of modern SQL databases.

    DDL,DML
1.1.3 Using SQL in Java
    JDBC --> often so tedious --> paradigm mismatch --> explore the mismatch problem by  asking what persistence means in the context of OO application developement

    first,let's  widen persistence from just storing data to a broader,more mature understanding of what is invovled in MAINTAINING AND USING PERSISTENCE DATA.

1.1.4 Persistence in OO applications.
    In an object-oriented application, persistence allows an object to outlive the process that created it. The state of the object can be stored to disk, and an object with the same can be re-created at some point in the future.
    (这段话说的太好了!一个OO app所操作的是活生生的对象,其所输入输出的最好也都是对象,而别成像RDBMS里所表现的散开的单个字段.一个Persistence所要做的也正是将RDBMS中单个的字段值转译成OO app所需的Object,并在OO app与BD间建立一个Object-oriented DataBase系统,从而在OO app与RDBMS间充当Proxy/delegate的角色)


    This isn't limited to single objects--entire networks of interconnected objects can be made persistence and later re-created in a new process.

    从data-level到object-level

    Almost all Java applciations contain a mix of persistence and transient objects; hence,we need a subsystem that manages our persistence data.

    When we discuss persistence in this book, we're thinking of all these things:
        Storage, organization,and retrieval of structure data.
        Concurrency and data integrity.
        Data sharing(上面说的那个concurrency实质上不就是说data sharing的么?为什么在这还要另外再提data sharing呢?).

    We're thinking of these problems in the context of an object-oriented application that uses a domain model.

    The business logic isn't executed in the database;it's implemented in Java in the application tier.This allows business logic to make use of sophisticated OO concepts such as inheritance and polymorphism.For example,we could use well-known design patterns such as Strategy,Mediator,and Composite,all of which depend on polymorphic method calls.

    If we consider SQL and relational databases again, we finally observe the mismatch between the two paradigms. SQL operations such as projection and join always result in a tabular representation of the resulting data.

    paradigm mismatch(就像人类一样,虽然都是做那些吃喝拉撒睡这样的活动,都由于语言、宗教、历史、地域、气候等的不同,就有了paradigm的差异,这也很像翻译,表面上看是两本字典的对照,可要想灵活自如start-of-the-artly做出高质量的翻译,就得综合考虑以上列举的诸多因素):
    当面对data-level的系统时,用SQL这样的语言.
    而对Object-level的系统时,用Java这样OOish的语言.



1.2 The paradigm mismatch (continued)
2
3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics