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
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
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.