Currently, Hibernate 3.x is the main Hibernate version used by enterprises . Here, Hibernate 3.6.10 is taken as an example. Beginners can download the corresponding version from the official website http://sourceforge.net/projects/hibernate/files/hibernate3/ . The download process of Hibernate 3.6.10 version is shown in Figure 1.
Figure 1 Hibernate download
Figure 2 Hibernate download
In Figure 1, click the 3.6.10.Final link to enter the download page.
In Figure 2, there are two compressed package links, among which hibernate-distribution-3.6.10.Final-dist.zip is the version under Windows, and Final indicates that the version number is the official version. hibernate-distribution-3.6.10.Final-dist.tar.gz is the version under Linux . Readers can download the specified version of Hibernate according to their own environmental needs. This tutorial downloads the Windows version of the ZIP archive.
After the download is complete, decompress Hibernate 3.6.10, and the directory structure after decompression is shown in Figure 3.
Figure 3 The file structure of the Hibernate compressed package
It can be seen from Figure 3 that the Hibernate 3.6.10 installation directory contains a series of subdirectories, which are used to store files with different functions. The following is a brief introduction to these subdirectories, as shown in Table 1.
Name | illustrate |
---|---|
documentation folder | Hibernate-related documents are stored under this path, including Hibernate reference documents and API documents. |
lib folder | Under this path, the core class library of Hibernate 3 and the third-party class library that compile and run depend on are stored. The required subdirectory under the lib path contains the JAR packages necessary to run Hibernate 3. |
project folder | The source code of various related projects of Hibernate is stored under this path. |
hibernate3.jar file | This JAR package is the Hibernate 3 core JAR. |
In actual development, you need to add the core JAR of Hibernate 3 and the JAR package in the lib/required subdirectory to the project. In addition, you usually need to add the JAR that Hibernate 3 supports for JPA and the JAR that implements the log function . When using Hibernate 3 to develop projects, the required JAR packages and their descriptions are shown in Table 2.
JAR package name | describe |
---|---|
hibernate3.jar | Hibernate core package |
antlr-2.7.6.jar | Language conversion tool, Hibernate uses it to realize the conversion from HQL to SQL |
commons-collections-3.1.jar | collections Apache's toolset for enhancing Java 's ability to handle collections |
dom4j-l.6.1.jar | dom4j XML parser |
javassist-3.12.0.GA.jar | Code generation tool, which Hibernate uses to extend Java classes at runtime |
jta-1.1.jar | Standard JAVA transaction (cross-database) processing interface |
slf4j-api-l.6.1.jar | Just an interface for integrating log4j |
hibernate-jpa-2.0-api-1.0.1.Final.jar | JPA Interface Development Kit |
log4j-l.2.17.jar | Log4j Logfile Core JAR |
slf4j-log4jl2-l.7.12.jar | A logging system used by Hibernate |
It can be seen from Table 2 that there are 10 JAR packages that Hibernate 3 depends on. Among them, hibernate-jpa-2.0-api-1.0.1.Final.jar is the development package of JPA interface, which is located in the jpa folder of the lib subdirectory of Hibernate. Since Hibernate does not provide log implementation, slf4j and log4j development kits are needed to integrate Hibernate's log system into log4j.
It is very simple to build the environment of Hibernate, just copy all the JAR packages in Table 2 to the WEB-INF/lib directory of the project. It should be noted that if the Hibernate framework wants to establish a connection with the database, it also needs to import the driver JAR package of the relevant database.