[Original] Pro hibernate 3 notes and summary (3) Chapter 1 hibernate getting started

Source: Internet
Author: User
/**
Author: willpower
Source: rifoo Technology (http://www.rifoo.com)
Time: 2006-05
Remarks: Reprinted please keep the above statement
**/

Today we will end the first chapter.

Let's take a look at the content generated by the database.

When creating a hibernate application, if a database exists, you do not need to manage the schema. If no database exists and it is a brand new application, you need to create a database schema (The schema here refers to the database structure, including tables, fields, indexes, etc. It refers to the SQL script file used to generate the database structure.), Pojo and ing files. Of course, there are also tools to help us complete these operations. The schemaexport tool can generate a database schema file directly from the ing file. The results are quite good. Since hibernate supports different SQL dialects (that is, it supports different databases), the generated schema also corresponds to the currently used database, such as MySQL and Oracle. Of course, you can also generate schema files for All Database dialects to facilitate application deployment.

The SQL script generation for database schema is similar to that for generating poing files from pojo:
Java org. hibernate. tool. hbm2ddl. schemaexport motd. HBM. xml

Okay, now we understand that, as long as there are any of the three things (schema, pojo, ing file), you can generate another two.

The following figure shows multiple hibernate generation methods:


The following is another form of interaction:


Once we have an SQL file and a Java source file (which refers to a pojo file, we can simply understand pojo as a JavaBean object ), we can generate database and class files. But in fact, if the database file and pojo file are complex, we may need to change the default options of these tools. Even so, these tools are very helpful in process processing.

Finally, let's take a look at the relationship between hibernate3 and ejb3.

Currently, the ejb2.1 standard does not provide an ORM mechanism, but the next-generation standard ejb3 will contain an ejb orm standard. Why study hibernate when sun's new standard comes out? Because the original authors of Hibernate are involved in compiling this ejb3 specification, and they have benefited a lot from the numerous successful ORM solutions. Therefore, Hibernate has a great impact on the design of ejb3.

Ejb3 supports and encourages the use of the transparent persistence of Entity Bean, which is similar to the pojo supported by hibernate. Therefore, Hibernate can use the entitymanager component of the EJB container. Hql of Hibernate is highly correlated with the new EJB Query Language (ejb ql), which may be related to the participation of the hibernate team in the formulation of the ejb3 standard.

Ejb3 also allows the relationship between entitybeans/pojos and databases to be described and declared in the deployment descriptor file. What's more interesting is that, ejb3 also allows these relationships to be expressed through entitybeans/pojos embedded java5 annotations. In this aspect, Hibernate 3 annotations can be directly supported.

In short, learning hibernate3 now will be of great help in the future, even if it is converted to ejb3. You can use the minimum effort to learn the future ejb3. At the same time, hibernate3 is currently the most powerful and persuasive ORM framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.