[Post] hibernate entry-detailed explanation of the role of the package

Source: Internet
Author: User
Tags xml parser ibm developerworks
Hibernate includes 23 jar packages, which are dazzling. This article will explain in detail the role of each jar package in hibernate, so that you can choose based on your own needs in the application.

Download hibernate, for example, the stable version 2.0.3, and decompress it. You can see that there are 22 jar packages in the hibernate2.jar and Lib directories:

Hibernate2.jar:

Hibernate library, there is nothing to say, the jar package must be used

Cglib-asm.jar:

Cglib library. hibernate uses it to dynamically generate Po bytecode. It is a very core library and must use jar packages.

Dom4j. jar:

Dom4j is a Java xml api, similar to JDOM, used to read and write XML files. Dom4j is a very good Java xml api with excellent performance, powerful functionality, and extreme ease of use. It is also an open source software that can be found on SourceForge. I can find an article on IBM developerworks to evaluate the performance, functionality, and usability of mainstream Java XML APIs. dom4j is outstanding in that aspect. I started using dom4j nearly two years ago until now. Now you can see that more and more Java software are using dom4j to read and write XML. It is particularly worth mentioning that Sun's jaxm is also using dom4j. This is a required jar package. hibernate uses it to read and write configuration files.

ODMG. jar:

ODMG Is An ORM specification, and hibernate implements the ODMG specification. It is a core library and a jar package must be used.

Commons-collections.jar:

One of the Apache commons packages contains some collection classes developed by Apache, which are more powerful than Java. util. Required jar package.

Commons-beanutils.jar:

One of the Apache commons packages contains some bean tool classes. Required jar package.

Commons-lang.jar:

One of the Apache commons packages contains some data type tool classes and is an extension of Java. Lang. Required jar package.

Commons-logging.jar:

One of the Apache commons packages contains the log function, which must be a jar package. This package contains a simple logger, but it has poor functionality. At runtime, it will first find log4j in classpath. If yes, it will use log4j. If not, find the java. util. logging. If not found, use simple logger. The emergence of commons-logging.jar is a legacy regret, the original Apache strongly urged sun to add log4j to jdk1.4, but the jdk1.4 project team is close to the release of jdk1.4 product time, therefore, Apache's requirements are rejected and Java is used. util. logging: This package has far worse functions than log4j and has average performance. Later Apache developed a commons-logging.jar to be compatible with two logger. Therefore, the underlying logger can be switched with the log program written in the commons-logging.jar. You can choose log4j, java. util. logging or its own simple logger. However, I strongly recommend that you use log4j because log4j has high performance and the log output time is almost the same as system. Out. On average, you only need 5 us to process a log. You can find the log4j configuration file that hibernate has prepared for you in the src directory of hibernate. You only need to download log4j on the Apache website. The commons-logging.jar is also a required jar package.

The jar packages required by hibernate are the above, and the rest are optional.

Ant. jar:

Ant compilation tool jar package, used to compile the hibernate source code. If you do not want to modify or compile the hibernate source code, it is useless. The optional jar package

Optional. jar:

Ant.

C3p0. jar:

C3PO is a database connection pool, and hibernate can be configured to use C3PO connection pool. If you want to use this connection pool, you need this jar package.

Proxool. jar:

It is also a connection pool, same as above.

Commons-pool.jar, commons-dbcp.jar:

DBCP database connection pool, developed by Apache Jakarta, and the tomcat4 connection pool is also DBCP.

In fact, Hibernate implements a very simple database connection pool. With the above three connections, you can select four different database connection pools on hibernate, which one to choose depends on your personal preferences, but DBCP may be more common. In addition, if you use hibernate in EJB, you must use the connection pool of the app server. Do not use the above four connection pools. Otherwise, container management transactions do not work.

Connector. jar:

JCA specification. If you configure hibernate as connector on the app server, you need this jar. But in fact, the app server will definitely carry this package, so it is actually a redundant package.

JAAS. jar:

JAAS is used for permission verification and is already included in jdk1.4. So it is actually a redundant package.

JCs. jar:

If you want to use JCs in hibernate, you must include it; otherwise, you will not need it.

Jdbc2_0-stdext.jar:

The extension package of jdbc2.0 is generally used by the database connection pool. However, the app server is always included, so it is redundant.

JTA. jar:

The JTA specification is required when hibernate uses JTA, but the app server will carry it, so it is redundant.

JUnit. jar:

The JUnit package is required when you run the test code that comes with hibernate. Otherwise, you do not need to use it.

Xalan. jar, xerces. jar, xml-apis.jar:

Xerces is the XML parser, xalan is the formatter, and XML-APIS is actually JAXP. Generally, app server will be taken, and jdk1.4 also contains a parser, but it is not xerces, but crimson, which is less efficient. However, Hibernate uses XML to only read configuration files, and the performance does not matter, so it is redundant.

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.