JDO

zhaozj2021-02-17  38

JDO

1 Java & Database Applications, JDBC

Since the inventions of Java, in just a few years, quickly occupying the application development market from the desktop application (J2SE) to the server (J2EE), and then to the small device embedded system (J2ME), and its language has drawn everything in SmallTalk. The concept of objects, get rid of C history, simple, free style has won the favorite of many developers. Starting from JDK1.1, Java becomes a practical language, not the new show that is visually and hurts; then passes through the large amount of JDK1.2 (especially Collection Framework), JDK1.3 Virtual Machine Efficiency (HotSpot), JDK1. 4 The length of the bolt, Logging, Regexp, Newio, etc.), now it is already a stable, quite famous. In the enterprise market, most applications are based on the database. The data is the life of the company, the traditional development language, including the process-oriented C, object-oriented C , variant of the Delphi (very good language, I used Four years), data-oriented PowerBuilder, etc., have shown a storm on the stage developed in the database. Java certainly won't let these, so JDBC appeared. With the help of JDBC, Java has also rapidly penetrates the market developed by the database, especially for the application development of enterprise server. Today, JDO has a very close relationship with JDBC, although JDO is not only for JDBC's data object packaging specification. Let's take a brief introduction to JDBC.

1.1 Hundreds of relational databases, ODBC

The history of the relational database is exhausted, I can only describe from my contact experience and what I saw, simply. At the earliest, the computer is only showing some large research institutions, not the prolidity of the Proan. Apple computer introduces the personal computer into the private, and then the IBM's PC standard is open, the personal computer is gradually popular, coupled with Microsoft's DOS operating system, and Borland's Turbo series language development environment, the people found that the original computer can do so many things ! Later, DBASE appeared, a simple relational database system, and SQL language. Later, Borland saw the market prospect of the database. It launched Paradox (also in today's Delphi and C Builder), which occupied most of the Jiangshan in the civil database, then, Borland simply acquired DBASE, and later purchased Interbase, keeping the leading advantages of the database market until Windows 3.0 appears. At this time, Microsoft launched 3.0 after Windows 1.0 and 2.0, and more stable 3.1 and Win32API, which created the dominant status of the personal computer desktop operating system. In the case of Borland unforgettable, it purchased the same Fox company with class DBase database technology, and quickly uses it, forming FoxBase, and then evolved into FoxPro, gradually exceeded Borland, becoming a large computer database. Microsoft re-rehabilitation, developing Access for the simple and low-load requirements database applications, winning the hearts of the majority of developers. Of course, commercial databases such as Oracle, Sybase, Informix are dedicated to enterprise-class database technology to become high-end leadership figures. Microsoft, certainly wants to be one of the high-end database vendors, so I develop a set of business-oriented applications, but very fast projects die, Microsoft is not willing, bought Sybase's underlying TDS technology, packaged into SQL Server, with Microsoft The highly ease of use, also occupies a lot of markets. When there are many database products in the market, Borland and Microsoft have found that they have a lot of database products, the market is not small, and different products bring different configuration tasks to users, which is not conducive to all products, so two Since the beginning of the database access, Microsoft launched ODBC, and the affinity of developers, gradually obtained, and Borland gathered IBM and Novell also launched the IDAPI database interface norm, which is the core of today BDE. However, Novell and IBM have been exited, only Borland is standing alone. However, Borland is a strong technical strength. Its technology has always been leading to Microsoft. BDE's performance is better than the initial ODBC. Later, Microsoft steals the teacher, putting the connecting pool and other techniques to ODBC, in Delphi3. 0 and its BDE gradually rushed up and exceeded it. Until today, BDE is still a database access standard on Borland's product line, and Microsoft is not an estimated BDE is still the winner of the market if it does not embed the ODBC and most database clients. However, Microsoft is the older who is playing with the market. Through the monopoly of the operating system, its database products and ODBC standards have finally occupied most developed markets. 1.2 Standard API from OPTIONAL PACK to JDK

After the Java starts to apply the database application, Sun will force the Java database specification. JDBC API is similar to ODBC. The underlying protocol accessed by the database is the most basic package, and then form a unified data access interface, database connection, SQL statement The handle, the result set, with an ODBC shadow. With convenient configuration, Sun is recommended to recommend a completely thin client Type 4 JDBC driver. This is a driver specification that does not need to install the database client, which is now using the most. Of course, in order to keep it compatible with the old database, the JDBC specification includes Type 1 drivers dedicated to connect ODBC and the Type 2 driver that need to install the database client, and the manufacturer's Type 3 that can be dedicated to JDBC services in the database server. drive. When JDBC appears, it is not part of a standard JDK, but is available as an additional package. Later, with the increase of database applications prepared by Java, and the JDBC specification itself gradually matures, JDBC finally became part of JDK1.1. JDBC is currently the latest version 3.0, as well as version 4.0 in discussion. In fact, the most used in development is still 1.0 API, 2.0 mainly increases the API, update batch, and other APIs, update batch, etc., 3.0 mainly increase the connection pool and updatable results. Collection features. 4.0 will be improved in terms of manageability, connection pool standardization. 2 Object-oriented and database

Now the programmer, no object-oriented. As the development concept close to the real objective world, object-oriented makes the program code more readily, design more reasonable. In the universal database application field, developers have never stopped the object-oriented pursuit. From the 1980s, there are many companies and research institutions in conducting research-oriented and database binding.

2.1 SmallTalk, C and C , Delphi-Object Pascal, Java

Object-oriented language, the earliest prototype, IBM's SmallTalk is the most popular, in SmallTalk, everything is an object, everything is class, it will play an object-oriented concept. Object-oriented programming has been a big step in the traditional way, making people realize that the original software can be written like this. However, due to the limited computer basic structure and the underlying hardware system and system software, SmallTalk does not promote to ordinary applications under the ideal performance, this is temporarily limited to the development of SmallTalk, then, C-language object-oriented version C A lot of people using C language, C quickly becomes object-oriented programming mainstream languages. However, in order to ensure compatibility with C, C retains many process-oriented traces, such as nausea, global variables, etc. Pascal's improved version Object Pascal is relatively safe. Later, Borland simply changed the Object Pascal, called Delphi, creating a new world-oriented programming new world, Delphi's rigorous grammar and rapid compilation attracting numerous application development Putting with Borland's perfect VCL component system, it is easy to easily, in addition, Delphi complete database components, it also makes it easy to develop database development, and Delphi will become a mature object-oriented development language. Microsoft certainly won't let these, by built-in MFC into the operating system, Microsoft's VC also grabs some markets. This is why Delphi developed the application after compiling the programs developed by VC and VB. In 1995, a development team of Sun was originally developed in the small embedded system. The result was unintentional to Liu Ying, which developed Java language. It is an object-oriented language that completely gets rid of the traditional language. Of course, It also retains some core (original type) of non-faceted objects to ensure speed. Java is now one of the most popular object-oriented languages. Of course, Microsoft also won't let it, and Microsoft that imitures immediately makes a C # coming, and retains some variant (referred to) in C # to attract traditional C developers. Regarding the respective features of these languages, it will not be described here. 2.2 Database and data objectification

The database is indispensable, and therefore, when the object is popular, the database manufacturer is also studying data objectization. These studies were beginning to have the beginning of the 1980s. The database's objectification generally has two directions: one is to join the object-oriented feature based on the mainstream relational database, so that the object-oriented service is provided, but the access language is based on SQL; the other direction is completely abandoning the relational database, with The newly-oriented concept to design the database, this is the object database ODBMS.

2.2.1 Relationship Database Objectivity, SQL99 and JDBC3.0

As many relationship database vendors began to provide objective services, their respective interfaces began to mutual compatibility. After some troubles, the relational database manufacturers feel the standardization, because the relationship between the relationship database is a big role in the world, and the SQL92 standard has played a lot. You can access high-performance commercial databases in a unified programming method. Relationship database vendors focus, re-enacting the objective service specification, forming the SQL99 specification, the contents of the object structure, etc., starting a new object-oriented relationship database (OrDBMS). JDBC3.0 is introduced in this case, which will regulate the Access API specification of object services in the relational database to provide access to ORDBMS for Java platforms. Of course, JDBC3.0 has also enhanced a lot of functions on traditional SQL operations. Oracle is a traditional relational database manufacturer, on an objective road, Oracle, of course, to add an objective features to invade the data objectified market, maintaining the leadership of Oracle in the database. If Oracle7.4 makes Oracle to all, from Oracle8, Oracle is a pioneer of the relational database plus object type. In Oracle8, we can define some data structures (RECORD), packing the normal types into data elements, and then can be accessed by the Record structure in the client, initially providing object-oriented database services. 2.2.2 Object Database

The object database is to design a new database type of the database with a new object-oriented concept. In this regard, it is mainly designed and developed in some university research institutions, and some products have also been formed, but due to market reasons (mainly related databases and market absolute leadership status) and some weaknesses of ODBMS (such as query The engine is difficult to optimize), making ODBMS uncommon. However, the object of the object database is still unsatisfactory. There are still some good products in the market, from commercial to free. At present, it is a leadership in the ODBMS field is Versant, FastObjects, and ObjectStore, and market share is gradually expanding. Free products include C written Ozone, pure Java DB4O, etc. There are also some research institutions to develop some underlying object-oriented database engines, but only provide some underlying APIs, do not provide management functions, and some algorithms provide open interfaces, let vendors choose and implement. For example, the SHORE engine of the US Wiscon University's computer system database group is a very good object-oriented database engine. Now some other research institutions and database vendors use it to complete their own special object database. For example, a database dedicated to geographic information, a database dedicated to cosmic space data research, and so on. The largest obstacle current object database is a lack of unified specifications, and each database vendor has its own access interface. Object databases are not just a basic database, which also involves inheritance processing, polymorphism and other realization, and standardized roads are of course difficult. This is also an important reason that the object database cannot be popular. Some agencies have put forward some suggested specifications, such as the ODMG specification proposed by a group ODMG of the OMG team of the CORBA standard, is currently 3.0, where the OQL object query language is quite attractive. There are also some neutral agencies to propose some other standardized object access API, or one of the specifications of object-oriented databases. FastObjects and ozone mentioned earlier are in line with ODMG3.0 specification.

3 Java object mapping

To say, in the eyes of the general developers, the database is referring to the relational database, so many applications still use simple JDBC to access the database. During the development of the process, everyone gradually feels the limitations of JDBC, such as calling complicated, easy to generate resource leaks, etc., there is a distance from object-oriented Java language, so many development teams begin to think about how to make data in application Objective modeling, then find a way to combine with JDBC, which is an endless object packaging technology in Java database development. 3.1 Object Packaging Technology

3.1.1 Traditional packaging and evolution

Traditional packaging as the name suggests, the initial packaging method, many companies have experienced this step, producing a lot of packaging methods of different styles. Of course, the author has also abundant attempts. For example, if we have a user class: public class user {public int us; public string name; public java.util.date birthday;} We can use it as a simple data class, then write some tool methods Implementation with JDBC interaction. These methods, we can put them in an additional tool class, or in the User class as a static method. These methods include simple increase, deletion, change, check (take oracle as an example): public class user {public int us; public string name; public java.util.date birthday;

Public Static User AddUser (String Name, Date BirthDay) THROWS SQLEXCEPTION {Connection Conn = ...; // Get a JDBC Connection PreparedState PS = Conn.prepareStatement ("..."); // Get a serial value as a user ID RSET RS = ps.executeQuery (); rs.next (); user user = new user (); user.Userid = rs.getint (1); // Read sequence value is a new user ID User.name = name; user.birthday = BIRTHDAY; PS = conn.preparestatement ("Insert INTO ..."); // Insert SQLPs.SetInt (1, User.id) of user data record; ps.setstring (2, user.name); ps.setdate 3, user.birthday; ps.executeUpdate (); rs.close (); ps.close (); conn.close (); return user;}

Public Static void deleteuser (int userid) throws sqlexception {connection conn = ....; // ...}

Public Static User getByid (int userid) throws sqlexception {// ...}

// ...}

The above is a simple data package, we can see that this is a very simple JDBC packaging, some code can be modular to achieve reuse. In addition, this code has a lot of hidden dangers, if there is an abnormality in the middle, it will cause the system to have JDBC resource vulnerabilities because the resources allocated by JDBC (CONN, PS, RS, etc.) are the garbage collection mechanism of Java virtual machines. Recycle. Therefore, we need to change the method of addUser look like: public static User addUser (String name, Date birthday) throws SQLException {Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; User user = new User () Try {conn = ...; // Get a JDBC connection PS = conn.prepareStatement ("..."); // Get a sequence value as a user ID = ps.executeQuery (); rs.next (); user. Userid = rs.getint (1); // Read sequence value is a new user ID user.name = name; user.birthday = birthday; ps = conn.preparestatement ("Insert INTO ...."); // Insert User Data Sqlps.Setint (1, user.id); ps.setstring (2, user.name); ps.setdate (3, user.birthday; ps.executeUpdate ();} finaryly {// Here you should pay attention to Turn off the JDBC Resources in the order created: if (rs! = Null) try {r r cclose ();} catch (sqlexception ex) {EX.PrintStackTrace ();} if (ps! = Null) Try {ps.close );} catch (squexception ex);} if (conn! = null) Try {conn.close ();} catch (sqlexception ex) {ex.printStackTrace ();}} return user;

All database access methods must make such packaging, when our data classes reach a certain number (such as more than ten, dozens), these methods account for a lot of code, maintain difficulties, and the BUG has increased, and It is not easy to troubleshoot, especially the resource vulnerability, this easily causes the BUG that causes the server stability problem. In order to maintain the pureness of the data class, we can concentrate the JDBC operation method to a public tool class, so that this tool class will be very large, but each data class will become very simple, this way, can be called It is DataAccessObject mode, which is equivalent to ValueObject in EJB, which is a pure object model that is detached from the details. These are the most basic storage processing, based on the basic increasing reform retrieval (the inspection of the inspection of the keyword ", we also need to make a complex match query (SQL), which makes our storage processing code further complex . Simply, we can write a similar approach: public static collection Findby (String SQL) THROWS SQLEXCEPTION {// ... (here Get JDBC Connection) Collection Col = New Vector (); ps = conn.preparestatement (SQL); rs = ps.executeQuery (); while (rs.next ()) {user = new user (); user.userid = rs.getinT (1); user.name = rs.getstring (2); user.birthday = rs .getdate (3); col.add (user);} return col; // ... (same before, here is the code for cleaning JDBC resources)} This is the basic definition of a query interface, and the language used in queries is still SQL. If we need to independent of the parameters from the SQL string to save database parsing time and standardize, we also need to pass query conditions as parameters to this method, and the interface is changed to: public static collection findby (String SQL, Object [] params) throws SQLEXCEPTION {// ... ps = conn.preparestatement (SQL); for (int i = 0; i ? And ... Of course, some development teams like to write all possible inquiry Tell a dedicated query method in which the corresponding SQL operation is completed, this is similar to EJBQL, but it is only the functionality implemented by the EJBQL in manual coding. This makes the query are limited, but can provide additional interfaces. There are also some developers to see that some query methods in each class make this class's code huge, maintain trouble, put all the query methods in a public tool class, just in the method to join A parameter: Class CLS indicates which object you need to query so that each data class is compact. Of course, this result is that public class becomes unusually large, who maintains whoever is unlucky, can be said to be sacrificed, happy team.

However, if this person is not good enough, the pressure is not strong, some changes to the data class may be hindered by him. At this time, "a doctor is a relationship, Wan Fu Mo." Now, we have realized the packaging of basic objects, and now you can start thinking about more problems. First, we may start from a normalized perspective, add a read-write accessor getter / setter to each property, in the previous User class, may we write the basic attribute part as: public class user {private int us; Private string name; private date birthday;

// The following is a getter / setter for the above attributes, generally can be generated using the IDE tool to generate public int getUserid () {Return UserId;} public void setUserid (int value) {userid = value;} public string getname () {Return Name; } public void setname (String Value) {name = value;} public date getbirthday () {return birthday;} public void setbirdday (date value) {birthday = value};

// ...}

In this way, a comparative specification data package is completed. In addition, we know that in the object-oriented concept, one attribute can be another object, that is, there is a reference relationship between the objects, this relationship is also divided into one-on-one, one more, more, more Several cases. From a established object, an attribute can be another object or a collection containing another set of objects. So, in our data packaging, of course, it is best to handle the relationship between the objects. Suppose now we have a data class group: public class group {public int grouid; public string groupname; public set users; // set of user} This is not simply indicated, and does not use Getter / setter. User has a reference to the GROUP: Public Group Belongto; here, user.belongto and group.users are a one-to-many relationship. How can I achieve the database in our data class? Even if you don't consider the reverse relationship of Group.Users, the use of User.Belongto is a headache. If we take out a USER object, it is also taken out while it is also taken out, and it can be guaranteed to get a NULL when accessing a user group. However, there are several disadvantages: 1. Access processing (JDBC) of the data class becomes complicated. You need to perform a lot of SQL reads, sometimes you only need to access the basic properties of the user, time and resources; especially for collection Pre-reading, more scary 2. If this logic, two-way relationship processing is dangerous, it is easy to fall into the dead cycle. If you want to avoid it, you must add some special mechanisms in class code, it is also very troublesome. 3. If the relationship between the object is more complicated, such as three, four objects are associated with each other, that is, a nightmare, writing and maintenance of the code is very difficult

So, many developers naturally retire step by step, only a groupid is only reserved in the User class, which does not save the Group object, which can turn the user.belongto attribute into an int type, and otherwise write a getter method: Public Group GetBelongto In the group class, you simply remove the Users property in the group class: public set getusers () {RETURN new hashset (user.findby ("SELECT ... from User where belong_to = ? ", new object [] {new integer (groupid)})); There is a speech error because SQLException is not a RuntimeException. Yes, it is true, but we will save these treated in order to simply understand, save these deals more directly.

In this way, in fact, our object relationship packaging has been named, and there are many complex codes used to access the reference objects inside the class, which has violated the original intention of our object relationship. Some developers don't even reserve the way to access the relational objects in the class, but to access another object class when the customer calls, such as: ... User = user.getbyid (...); // Target object Take some access, such as the name, etc. Group Group = group.findbyid (user.belongto); // Some access to Group objects, such as display group name, etc. ...

In such a code, in fact, we have fundamentally returned the starting point of the relational database. How big does this differ from the direct access data table? It is just that a layer looks like an object-oriented skin. Unfortunately, this approach is still in many applications.

From the foregoing details of these object-oriented packaging, we can see some of the main defects of this traditional packaging:

3.1.1.1 Database Naming and Object Design Naming Consistency

Many times, we are interested in designing a class diagram, and after review, start the database packaging, this time, find some attribute name conflicts with the keywords in the specific database, can not be used as a table name Or the field name, you must use additional names in the data table design, or it is very troublesome to use quotation marks. Thus, someone who writes the database processing code has opinions, he must clearly remember what the property name is in the class, what is the word name in the table, after the class is gradually increased, especially a class After the changes, or after a long time needs to be changed, the code maintenance personnel should be crazy when they go to handle these JDBC code!

3.1.1.2 The inquiry of the object is still limited to SQL

This is also the simplest packaging method to get rid of a place where the relational database is. Also said, some naming conflicts brought a lot of maintenance work, and the naming system of the data table must also be retained, not the naming system of the object class. This will make the caller still need to clearly remember two sets of naming systems, regardless of time, or if there is a flow of developers. In addition, for the commonly needed, it is difficult to use development, and these places still cannot break through SQL restrictions.

3.1.1.3 SQL resource takes more

When processing an object collection or handling a collection type property, we can only process all transactions in the same connection, which requires all the objects in the collection, and if the collection is large, it is easy to cause database congestion. , Make the performance big discount, it is reversed. Optimization in this area is also a lot of developers have been working hard. 3.1.1.4 Object Relationships Complex

As mentioned earlier, the relationship between the objects, ordinary packaging technology is a surface process, and the caller still needs to process with a large number of code, and this is only read, in the write relationship There will be more details when attributes require processing.

3.1.1.5 Object-Oriented Features You can only apply a small part

Object-oriented packaging to the foregoing, it is only very basic, and the object-oriented essence: inheritance and polymorphism, there is no help here. We gave up many reasonable designs to move into the database.

The above is the main defect in basic data packaging, and more small problems also require additional processing. However, the responsible developers will certainly don't give this good break. They think that they can use a better way to achieve the relationship between objects, and will also add some of the mechanisms of delayed access, and reference the reference between objects When you need it, you need to connect to the database data, inherit, on the inheritance of the class, they also try to get it in the database package. Thank you, some experienced teams have been contributing to their results in some improvements, and independently, becomes a reusable component. This is also the object packaging product that appears, including commercial and free.

3.1.2 Products Packaging Middleware

After the object-oriented packaging product, gradually promote open, called relationship / object mapping: O / R mapping. Moreover, in the process of productization, the product provider has gradually provided more functions in the product. First, some automatic name converters can be applied, automatically convert the class names in the customer code, and automatically transition to the corresponding database structure namespace, so that it is no longer concerned about the specific database structure when applying development. No longer need to remember differently naming systems, just need to be developed according to class maps. After that, the development team of these O / R mapping products has taken a big step forward: introducing the lexical analyzer, providing an object-oriented query language! The query of many object relationships makes the application development very convenient, making the O / R mapping product a new step.

3.1.2.1 Toplink

Toplink is a very early product, originally to C , and later realize Java mapping. Toplink is excellent, powerful, and provides a unique query filter mechanism, and it is very effective in processing and inquiry for relationships, so toplink has gradually wins from commercialization O / R mapping products, becoming the best in the market. Mapping products. It is also because of this, the biggest relationship database manufacturer Oracle acquires its manufacturer to provide the most powerful database and the most powerful object map.

3.1.2.2 CaStor, Hibernate

Although Toplink is powerful, too powerful things are unable to forget, Toplink starts to lock users to their own products, and the query method is most prominent. Its query system contains a lot of awkward concepts (in my opinion), but developers can only accept this for the functions that the usual O / R product cannot achieve. Slowly, also generate complaints, plus its high prices, so many new and old users are still. So, the free product begins to rise. There are many kinds of free O / R mapping tools, which only mention two of these most influential: Castor and Hibernate. CASTOR is an EXOLAB organization development for Java-oriented packaging tools. Its biggest feature is to achieve most of the ODMG OQL specification. On the query, you can query the same class diagram like an object database (later). Its principle is to achieve the settings and read of the attribute through the Java Reflection API. However, due to various reasons, Castor later updates are getting slower and slower, and eventually stopped in 1.0, it has become an O / R mapping product that has not been left to 1.0 official version. Anyway, it is still a quite a good product. Hibernate is a very hot O / R mapping product. It is currently 2.0, which is as strong. It also uses Java Reflection API to perform the settings, but its query language is a relatively unique system, this It is a bit similar to Toplink, but Hibernate is more affinity, more convenient to the relationship, but compares to Castor, is still a little bit messy in terms of convenience and norm. For the current situation, Hibernate's number of users and technical support are strong. 3.2 Object-oriented database query

During the process of object-oriented research on the database, the developers and designers of the software world discovered that the database can be an object-oriented query for the database is to completely object-oriented to the database. This is reflected in our use of a new database query language, which can be queried in the database very simple and easy to understand. A typical example is as follows: Suppose we already have the two data classes mentioned earlier: User and Group, there is a pair of relationships between them: user.belongto and group.users. There have been many instances of these two classes in the database, and the relationships between each other. We can use the following object query language to query the eligible User object: select * from user where user.belongto.name = 'group1' or select userid, name from user where user.belongto.name = 'group2', etc. . From this, we can see that by using the object-oriented member attribute specifier "." Can let us reach the effect of the SQL, in fact, the first query SQL equation is: SELECT A. * from user a, group bwhere a.belong_to = b.Group_idand B.Name = 'group1'

It can be seen that the object-type query language is simpler, and more meaning is more clear than the SQL language that implements the same function. It is more clear and more in line with the user's thinking habits. When the class diagram is more complicated, this new type of query language reflects an absolute advantage when the class diagram is more complicated.

3.2.1 Odmg, OQL, Java Binding

During the study of the object-oriented query language, developers have gradually realized similar query languages, and then they will do everything else to make a long-term supply, ultimately in the unity of ODMG organizations (www.odmg.org), forming standardized languages: ODMG OQL This is a database query language that completely faces the object, the syntax is similar to the previously mentioned, but considering a broader situation, the statement is more simple and rigorous. OQL is not for some language, it can be applied to many develop languages, it is just like SQL is just a pure string query statement, because the relevant class information must be provided in object-oriented queries, so OQL needs Realize some specific APIs in the programming language. At present, ODMG's OQL has been normalized to SMALLTALK, JAVA, C . In object-oriented programming languages, in ODMG specification, these modules are referred to as SmallTalk Binding, Java Binding and C Binding. However, due to historical reasons, ODMG did not have a wide application like imagination. In the existing more than a dozen object-oriented databases, there is less and less of the ODMG OQL specification. At present, there is only FastObjects, Ozone these products adopted this. Specifications, while larger companies like Versant have not taken OQL to query the database, but they define their own API, called VQL (Versant Query LanaGuage). In the O / R mapping product before JDO, there are also some products to use OQL (sometimes its subset), such as Castor, Apache's Jakarta Group developed OJB, etc. 3.2.2 Third Party Agreement

The software world is a colorful world, there is always some good things that have constantly emerged. There are also some organizations for object-oriented databases to develop their own set of object database query languages, their own specifications. However, these specifications have relatively, the influence is much smaller. Compared to ODMG, it can be said that the application range is too small, not to mention the standards that are widely used in SQL.

3.2.3 EJBQL

In order to make Java applications in enterprise database applications, SUN has spared no effort to promote J2EE. In 2001, the EJB2.0 specification has been introduced, which contains a characterful inquiry-oriented EntityBean inquiry language: EJBQL, functionality is similar ODMG OQL, but only in the application descriptor when the EJB is released, it cannot be dynamically used in the program. This is the biggest weakness of EJBQL, perhaps the EJB3.0 specification will be dynamized, but it is not that day, most of the world is no longer look.

3.2.4 JDO

JDO has recently specified an object query language specification, called JDOQL, compared to OQL, JDOQL combines many elements in the query language with Java language, some people feel trouble, some people feel the norm, Comments are different. From the perspective of the author's personal point, it is conducive to the database application, no newcomers who have used SQL quickly habits JDOQL, but in fact, how many people will not write SQL, did not understand the relational database Write the database application with JDO? After all, the market explains everything. Personally, how much is in JDO's query for database objects, and if it is more simplified, it will be more attracted to developers using traditional SQL.

4 JDO History and Main Products

Speaking of JDO, it comes from a special background. After java language reaches a more practical purpose, enterprise-class database applications are also an important part of the software development market. After SUN sees this, I also hope to develop market, market capture market through Java's powerful weapons. Share. After JDK1.2, Sun also launched EJB-oriented EJB for enterprise, standardizes Java-based middleware server framework, which is J2EE. However, in JDK1.2, Java's speed is still not comparable to traditional C / C and Delphi. In order to prevent the industry's passion from Java, SUN announces that it will join a powerful virtual machine technology in JDK, including more advanced garbage collection algorithms and more optimized Java byte code recoiling technology (equivalent to JIT, JAVA Instant compilation technology). Hotspot has attracted great interest in Java focus, but Sun's HotSpot is dragged again, and finally, when you come out in JDK1.3, the performance is not as good as expected, there is a section of code generated by C compilation. distance. At this time, everyone began to suspect to Sun, and Sun knows this, so the attention of the public quickly transferred to EJB, from EJB1.0 to EJB1.1, then to EJB2.0, the industry started to pay attention to J2EE Intermediates technology. Soon, the developer found that the use of EJB to write database applications or a big difficulty, although there is really great value in distributed technology EJB. At this time, Sun decided to launch JDO technology as a lightweight Java database access specification, and this is also welcomed by many traditional O / R mapping markets. In order to distinguish between traditional O / R mapping, Sun is positioned at high gestures at a high gesture not just a Java specification for relational databases, but for all storage technologies, including object-oriented databases and other types of storage systems (such as File), just like EJB EntityBean, though. As far as the author's perspective, this approach allows the first edition of JDO to abandon the functionality of the traditional O / R mapping provided by the relational database provided by the traditional O / R mapping, which can be considered a disturbance. 4.1 Specification proposes, JSR

JDO was earliered by Sun convened a large number of O / R mapping development teams to focus together. First, the JDO needs to be included in the conference, and then officially propose a Java specification request (JSR-12), officially started the JDO specification. Formulation. Here is the main milestones. JSR # 000012 Approved in July 19991999-8 Group: including Sun, Apple, BEA, IBM, Oracle, SAP, WebGain, etc. 2000-6 completion of the disclosure of the draft 2000-6 introduced 2001-3 Final draft 2001-3 Final 0.932001- 5 Final Draft 0.96 Release 2001-6 Start 2001-11 Final Draft 2001-11 Final Draft No. 2002-8 1.0.1 Revised Edition 2003-8 2.0 Specification Launched ...

4.2 Oracle and JDO

As an important member of the JDO expert group, it is clear that the Oracle status of the largest relationship database manufacturer is apparently non-common. In the JDO specification, Oracle can also be said to have a hoe-sweating, a lot of API's formation, Oracle provides a very important reference, and the final vote Oracle is not hesitant. However, the world is always changed, and when JDO1.0 is released, Oracle acquires Toplink, which makes Oracle's identity and complex. Toplink is a commercial product, and Oracle is also a typical business that is pursuing interests, this is a typical business with JDO's open spirit. Therefore, we see the later Oracle's unprically attitude toward JDO, even in the Javaone conference, someone informally attack JDO from Oracle's perspective. 4.3 Main products and their own characteristics

At the same time as the JDO specification, several major JDO products have appeared, with the US object-based database-based FastObjects J1, France's support Versant object database, file database, mainstream RDBMS Lido, South Africa JDogenie, Germany's JRLAY, etc. These are very good JDO products. Here is the impression of my major product: Lido (Libelis, France), I am mainly through Lido products, it briefly solves the use of JDO in a picture in March 2002. And advantages. This tutorial can be downloaded here: http://www.objectWeb.org/conference/jdo.pdf. Lido's features are large, support file database, RDBMS, ODBMS, and even XML databases. But the configuration is more troublesome. The latest version is 2.0RC. Kodojdo (US Solarmetrics) Kodo is one of JDO's medium-sized pillars. When JDO1.0 has not passed, it is a relatively mature product, which is characterized by focusing on performance and stability, and the latest version is 2.5.0. It is the most customer products. JDogenie (South Africa HemSphere) This is the most recommended product, the latest version is 1.4.7, the performance is good, the stability is still to be verified, but it has a biggest feature: good integration, the most easy to learn, its company CTO David Tinker is also a young man, adopted a lot of netizens' opinions to improve the product, mainly in configuration, there is a special graphical interface tool, which can be configured, database generation, object query, etc. Very practical function. JRELAY (Germany Objectindustries) This is also a more early product, and a GUI tool is used for configuration. When this tool is still relatively convenient, but more than a year, it seems that there is no progress, the latest version is 2.0 I tried it for a while later, I didn't follow up. Frontiersuite for JDO (US Objectfrontier) This product is with JRELAY, KODO, which is an early JDO three main products, which supports forward development and reverse development (Reverse Engineer). Its features are relatively convenient in reverse engineering (from the table structure to generate data classes), and the combination of UML is also very strong, but the configuration is complex when it is actually running. TJDO (a group of cross-borders) This is a free product formed by adding some extension features based on Reference Implementation, and the latest version is 2.0beta3, but progress is slow, this The version has already had a few months without further updates. 5 Current status and future outlook

Since the official announcement of JDO1.0 in April 2002, each product has an endless, from commercial to a free level, has a good product. Like KODO, LIDO, JDoGENIE and other products have been mature, consider investing in development. In August 2002, JDO launched 1.0.1 revised version, fix some text errors in version 1.0 specification, and slightly improved partial abnormal definitions, but the change is not large. From now on, in addition to KODO has some universities projects, it seems that it has not seen the application of JDO development. After all, JDO is a new technology. It is not much from the concept to the practical application, and these products are configured, and the convenience of convenience in use is always improved. Therefore, truly use JDO to develop The user of the project also Liao Liao, at least I still don't know which projects use JDO. I also try to use JDO to develop projects, but because some of the JDO1.0 versions are not perfect enough hard injury (such as do not support relational database statistics), I am still in the wait-and-see stage for JDO. Among the JDO2.0 Planning Conference conducted in mid-August, the representatives of various JDO products, JDO technical consulting companies, and JDO research institutions from all countries have gathered together to summarize the users of JDO2.0, proposed. A new topic, and identify the person in charge of the JDO specification for each topic, such as the high-grade FetchGroup feature is responsible for the best JDogenie's CTO David Tinker, and is responsible for the Managed-RelationShip feature by KODO. User requires the most JDO objects with the PersistenceManager's narrow / heavy link features from Sun's Craig Russell personally, and so on. The most attractive JDO2.0 topic, the author's personal consideration is a child-specific JDO / R specializing in the relational database. This is also my most concerned, which will make the current JDBC development will be completely replaced by JDO, and Ensure the development process maintains object-oriented features. There are also some features that map a class to multiple tables, which will facilitate DBA to change the data table structure as needed without affecting application development, achieving better performance. Similar new features, it is roughly, after these are standardized, I really don't know what extension characteristics of each manufacturer can do, maybe the manufacturer can only be technical support services and product performance. Of course, there is a final price competition. Said so much, I think everyone cares about when JDO2.0 can come out, when can we use it, when is there a Chinese version of the product, how is the price? These problems are currently unable to answer one by one, and can only explain it based on the information you have mastered. According to the JDO2.0 launched in the JDO2.0 in the conference, the official version of the JDO2.0 will be officially completed after 18 months. How does the manufacturer will provide a standardized product after the official completion? This question doesn't have to worry, because the norms will continue to announce public preview (Public Review) during the formulation, so that manufacturers can implement the functions, etc. After the specification is officially completed, there will be no too much change, manufacturer It will not take too much time to follow up the final norm. So, I estimate that after year, we can develop it on JDO 2.0. As for the price, the 1.0 specification product preliminary impression is that each developer needs a license, a License is about $ 2,000.

If the price of JDO2.0 products remains so expensive (at least for Chinese users), we also have a lot of free (such as JPOX, TJDO) or a semi-free (such as jcredo) products. The last question about the Chinese version is to wait for the manufacturer to investigate the Chinese market, or see if there is a domestic JDO product. However, while the JDO2.0 specification is developed, we can first set the power to popularize them, enabling developers using Java language to develop developers to understand JDO, understand JDO, and even use them to use it to project development. in. Perhaps, JDO's goal has attracted people outside the Java world. Microsoft discovers this, and immediately plans to join a middleware that is imperative in the .NET system, specifically using ObjectStore products, ObjectStore is a simultaneous JDO and .NET-DO (aunt, using this name) company. Here, the author can boldly predict that JDO will be in the Java world within the next year!

5.1 little flower

At the Javaone meeting held in June 2003, JDO has attracted great interest. Many developers or development organizations have had great interest in it. It is often exposed in major website media, most of them have a good evaluation, of course, Some negative evaluations. However, the report on the website is not trustworthy, such as the authoritative website of the server, introducing the Javaone Conference on the next day of the Javaone Conference on the next day of JDO, there is misleading, from the content of the report, as if the meeting The last five minutes used to Q & A and communication are occupied by a good thing. This person is desperately advocating Oracle's Toplink solutions and some ease of improvement, thus attacking JDO's market prospects. Later, when I exchanged this information with David Jordan of the JDO expert group participating in the meeting, he corrected my mistakes. The actual situation is: that good thing is a positive JDO assistant, he spent more than five minutes. I am actually some API changes that the Oracle's Toplink improvement is actually plagiarging JDO's concept! However, it is the same, this good matter occupies everyone's question, so that this meeting is still in the middle of it.

The copyright of this article belongs to the author, but welcome to reprint, the premise is to indicate the source and the original. In addition, welcome to some of my articles in my column, and make valuable comments!

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

New Post(0)