Notes Object Persistence

III. Java domain objects used in the comparison lasting technology
Java in the current total of five kinds of commonly used model to achieve lasting:
1 jdbc direct access to the database
2 active domain object model
3 cmp mode
Mode 4 orm
5 jdo mode

1, jdbc way to achieve database access methods in the business directly embedded sql statements, sql statement is relationship-oriented, rely on the relational model. Therefore, the advantages of jdbc means are straightforward, in particular, is very convenient for small applications.
But this realization also jdbc application to have the following shortcomings:
(1), the realization of business logic and database access code with code doping, so that program structure is not clear, poor readability.
(2), embedded in the program code for the relationship between the sql statement, so that developers can not use object-oriented programming thinking.
(3), the relationship between business logic and data model to bind, if the relationship between changes in the data must be manually modify all of the relevant code sql statement, which has been the difficulty of maintaining the software.
(4), if the program code in the sql statement contains a syntax error in the compiler can not check this error, only in the run-time error can be found, which increases the difficulty of the debugging process.
It is because of the above-mentioned shortcomings, in order to make business logic and data access details of the separation, there have been several models below.

2, active domain object model
Entities active domain object is a form of domain object, which encapsulates the relationship between implementation of data models and data access details. J2ee architecture in, ejb session ejb components and entities are divided into ejb. Ejb session usually business logic, and that the business entity ejb entity. Entities are divided into two ejb: ejb itself from the management of persistent, that is, bmp (bean-managed persistence); by the ejb container managed persistence, that is, cmp (container-managed persistence). bm p active domain object model is an example of, bmp that management by the entity's own data access ejb details.
Active domain object model has the following advantages:
(1), in the physical domain object in the package of its own data access details, the process of domain object be fully responsible for business logic, so that program structure more clearly.
(2), if the relational data model changes, only the active domain object need to modify the code, do not need to modify the course of the business domain object methods.
Active domain object model has the following shortcomings:
(1), in the physical domain of the realization of the object still contains the sql statement.
(2), each entity is responsible for their own domain objects to achieve data access. This fragmentation of responsibilities in a number of targets, this will lead to repeat the achievement of the target domain entities of common data access operation, resulting in duplication of code.
Active domain object itself is located at Business Logic Tier, the active domain object model, the entire application is still the three-tier application structure, and not isolated from the Business Logic Tier independent persistence layer.
3. cmp mode
J2ee architecture in, cmp (container-managed persistence) expressed by the ejb container to manage the persistent ejb entity, ejb container package object - the relationship between mapping and data access details. cmp and orm similarities lies in the fact that both provide object - relational mapping services, have the task of object persistence from the business logic separated. The difference is responsible for cmp persistent ejb entity components, which is responsible for orm persistent pojo, it is the ordinary form of java bean based on the domain object entities.
The advantages of model cmp:
(1), he is the ejb-based technology, sun j2ee system is the core of the universal access to the industry support, including major vendors and open source organizations. If you choose it for enterprise development, technical support will be very comprehensive.
(2), improved functionality, including support to improve matters, ejbql query language, transparent distributed access, etc.
cmp model shortcomings are:
(1), developers of the entity must comply with the norms j2ee complex, and not the number of similar requests middleware orm.
(2), physical domain only ejb in ejb container to run, and can run in any pojo a java environment.
(3), although according to the j2ee specification, ejb should be a portable component, the practical application of a very limited indeed. Orm middleware and this problem does not exist.
4. orm mode
orm-object/relational mapper, that is, "the object - relational data mapping components." The o / r, that is, object (objects) and relational (relational data), expressed the need to use object-oriented data and relational development. Orm in the field of modeling for object / role modeling (Object Role Modeling). Here is another "o / r mapper" instead of "o / r mapping". Relatively speaking, o / r mapping described is a design idea, or achievement of the mechanism, and the o / r mapper refers to the o / r principles of design of the framework of a lasting (framework), including o / r mechanism, sql self-generation, services processing and cache management.
Java bean based on the general form of the entity known as the domain object pojo (plain old java object), which means the oldest and also the general meaning of the java object. Orm mapping tool with a variety of increasingly sophisticated and popular, pojo have to reproduce glory, which the cmp-based entity ejb compared to simple and high portability, so the joint use of tools and orm mapping pojo, has become an increasingly popular and used to replace the persistent program cmp. pojo is unable to do the shortcomings of long-distance calls, do not support distributed computing.
Orm common middleware are: hibernate, apache ojb, cayenne, jaxor, toplink, etc.. Orm of the hibernate lightweight which gradually established model java orm in the leadership structure, and even to replace the complex and cumbersome ejb model become the de facto industry standard java orm. And many of which have been designed to absorb j2ee standards body to become the latest in ejb 3.0 specification standards.
5. jdo mode
jdo is emerging in recent years, technical data persistence, java data objects (jdo) is the sun corporate semantic description of object persistence standard api. Strictly speaking, jdo not object - relational mapping interface, because it supports the object to any of a persistent storage system, including relational databases, object-oriented database, xml-based database, as well as other proprietary storage systems. Since the relational database is the most popular storage systems, and many are included in the realization of jdo object - relational mapping service. jdo model's advantages are:
(1), easy to use, do not need to write a large number of useless interface, do not need any special type of inheritance, the only need to do is to document your class do you enhance.
(2), the true object-oriented. Jdo use the java process is a real object-oriented, no longer need to care about what form inside the database, access to java object is targeted, all the database tables are automatically generated.
(3) to facilitate the transplant database. For database applications in addition to time for a jdbc driver, to change the database url, no need to make any changes to procedures.
jdo model's weaknesses are:
Because it is new and emerging technologies, some of it giant has not given adequate support, including ibm, oracle, bea.
IV. Summary
On the dispute over the merits of these technologies has just been born from that day on they never stopped, and the various factions have never been able to convince the other side. For application developers, the controversy aside purely to the technical merits and there is not much significance. There is no best, only the most suitable. When doing development to choose a most suitable technologies in their own, it is enough. In general, jdbc-oriented rdbms, relational database more appropriate model-driven applications such as statistical tables of data to generate the application of such statements. ejb in j2ee application server technology as the center, if the application does need to be flexible can be a statement of the affairs of the border, the need to support large-capacity access and uninterrupted service, the need for application server cluster, then choose your ejb. jdo is object-oriented, for a domain object-centric applications, including maps, the application of tree models, jdo be the first choice.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Notes Object Persistence

  • hibernate Technical Study Notes (first)

    Introduction: Model does not match (impedance mismatch) java object-oriented language, object model, its key concepts are: inheritance, association, polymorphism, etc.; database is the relational model, its key concepts are: tables, primary keys, for ...

  • Javascript Object Model

    Javascript Object Model

  • WEB test summary (architecture, design) the best part

    1, for a total test architecture 1) thin-client, business logic rules in the server-side implementation of the majority. Such as news sites, portals, information websites. 2) fat client, a high security requirements, frequent interaction, complex bus ...

  • What is the JPA

    Same, JDO, also started compatible JPA. At the field of ORM, it seems that JPA is a benevolent government, is the normative specification. At the support of major manufacturers, JPA use became widespread. 2 Spring Spring + Hibernate often referred to ...

  • Hibernate II Study Notes

    11. Many-to-many Of many that can be converted to two one-to-many many-to-many data only from one end of the maintenance, if at both ends of maintenance, will be reported to the conflict between form the primary key of the error message. Many-to-many quer

  • Object-oriented design principles 11

    What is object-oriented design? Contains what? The benefits of it are what? Required to pay what you do? In today's age, ask these questions seem to be foolish, because this year almost every software developer knows how to use some sort of objec ...

  • FLEX: integrating Spring + Hibernate

    Before a friend also wanted to study development of FLEX. Asked me to help him to be a small sample. Spent a weekend time, to integrate a sampleproject. Client: FLEX Server: Spring2.5 + Hibernate3.2 + Hibernate-annotations3.3.1 + MySQL5 FDS: BlazeDS3 ...

  • Java technology 25 study points

    1. You need to master the object-oriented analysis and design (OOA / OOD), involving patterns (GOF, J2EEDP) as well as the integrated model. You should understand the UML, especially class, object, interaction and statediagrams. 2. You need to learn basic

  • In the servlet use Bean

    According to Sun's definition, JavaBean is a reusable software components. In fact JavaBean is a Java class, through the package into a property and methods of treatment of a function or a business object, referred to as bean. Because JavaBean is ...

  • Java Technology wishing cow needed 25 points of study

    1. You need to master the object-oriented analysis and design (OOA / OOD), involving patterns (GOF, J2EEDP) as well as the integrated model. You should understand the UML, especially class, object, interaction and statediagrams. 2. You need to learn basic

Leave a Reply

Recent
Recent Entries
Tag Cloud
Random Entries