Kodojdo Guide (the first two chapters)

xiaoxiao2021-03-06  76

Chapter II: JDO is a specification established by Sun to implement the transparent persistence of Java object transaction data storage. This document is an overview of the JDO unless specifically declared, the description of this document applies to specific implementation of all JDO specifications.

1.1 Reader Hierarchy This article is suitable for developers who want to understand JDO and practice to daily work. You should have a deep understanding of Java and object-oriented programming concepts, and familiar with XML. And you can have experience in processing and persistence data. If you want to know all aspects of JDO, then you should ignore this article, read the official JDO specification. SUN website provides its download.

1.2 Transparent persistence information is generated in the program, and data exists without relying on the program, called persistent data. Both of the multi-complex programs use persistence data: For example, the GUI program needs to remember the user parameters, the web program is going to track Users in a certain period of time and more. For developers, only a small amount of or not doing any work, you can complete the storage and reading of the persistence of persistence. For example, Java serialization is a form of transparent persistence. Application serialization, you can store Java objects directly to a file with little work. But as a transparent persistence mechanism, serialization and JDO comparison Get up, it is eclipsed. The following will make JDO and serialization also have a comparison of other mechanisms that implement data persistence.

Chapter two:

What is JDO?

For developers, there are already a variety of technologies that achieve persistent data access, such as serialization, JDBC, object-relational mapping tool, object database, and EJBS. So why to introduce another framework? The answer is that the above-mentioned persistence data access technology has a certain degree of defects, while JDO efforts to overcome these defects. The following table lists the contrast of these technologies.

1. Serialization is the internal implementation mechanism of the Java language, which can convert objects to a series of byte codes, save to files or via network transmission. Serialization is easy to use, but the function is very limited, it is accessible to the entire object, not suitable The processing of a lot of data. When the information is updated, if an error occurs, the change does not be revoked. So it is not suitable for the data strictly integrated application. Multi-threaded programs cannot read the same serialized data, otherwise it will happen Conflict. And you can't query. The above factors make sequentialization to trivial persistence requirements, almost useless.

2. Many developers use JDBC to operate persistence data in relational database. JDBC overcome many of the shortcomings of serialization. It can handle large amounts of data, provide data integration mechanisms, support data concurrency, and can be queried in SQL. Unfortunately Yes, JDBC has lost sequential ease of use, and the relationship example of JDBC is not designed for storage objects. So forcing you to abandon object-oriented programming ideas when considering data processing, or to find an object-oriented Concept is mapped to the database.

3. Some software companies develop their own technical frameworks, implement objects and relational data sheets. These objects-relational mapping products allow you to focus on how to translate between objects and relationship examples. However, these products have their own A large number of APIs, write this single manufacturer when you have written. If the manufacturer does not correct the bug's bug or increase the price, when you want to use another product, you have to override all of the persistence data. The code is operated.

4. Sowing of the mapping object to the relational database, some software companies have developed new databases that implement object access. Usually, this object database is easier to use by object-relational mapping software. Object database management organization (ODMG) intend Develop the standard API of the access object database, however, the manufacturer of the object database responds to ODMG suggestions. Therefore, manufacturers dependent. Many companies hesitate to choose new object database technology, after all, the relationship database is examined. Object database system There are few data analysis tools, and huge amounts of data have been stored in the old relational database. For these reasons, the object database is not as popular as its creator is expected.

5.j2ee introduces EJBS, entity EJB, such as an object-relational map, provides persistent data for persistent data. However, entity beans are not limited to relational databases, and the persistence information provided in EJB may be from EIS. And other storage devices. Moreover, EJB uses strict standards to make data easily transfer between different vendors. However, the object-oriented concept of EJB is limited, advanced features such as inheritance, polymorphism, and joint relationships disappear In addition, EJB writing is difficult, need to run on a large expensive server. EjB, especially session beans and messaging beans, do not have other advantages. However, the JDO specification details how to integrate these to JDO.

6. JDO combines the best features that the above mechanisms can provide. In JDO, writing a semiletable class is as simple as writing a sequential class. JDO supports big data sets, data coherence , Concurrency use and JDBC query capabilities. Like object-relational software and object database, JDO allows the use of advanced object-oriented concepts such as inheritance. Similar EJB, it is through strict specification description, it avoids manufacturers' exclusiveness, also like Like the EJB, JDB does not require. JDO implementer can store objects to relational databases, object databases, or any devices that support persistence storage. Note: By default, Kodo JDO stores objects through JDBC to the relationship Database. Users can customize other data storage methods.

For many applications, JDO is not perfect. But it provides alternatives for persistence mechanisms. And exciting alternatives.

转载请注明原文地址:https://www.9cbs.com/read-95064.html

New Post(0)