I always wanted to abandon myeclipse. Today I finally found the reason why I don't need it. There are so many plug-ins in eclipse that I can do anything. The following describes how to use hibernatgatels for hibernate development.
Install the hibernate plug-in
Method 1
(Optional), select help-software updates, open the available software tab, click Add sites, enter the online installation address of the jboos tool and hibernate tool, and then select install hibernate toolsjboos and tools development release, display
500) This. width = 500; "border =" 0 "width =" 500 ">
Wait until the installation is successful. Because many jar packages need to be downloaded during the installation process, depending on your network speed and time required, after eclipse is installed, you will be prompted to restart and install eclipse. (Note: Install hibernate tools before jboos tools development release)
Method 2
Generally, I like to download the required plug-ins and configure them myself, so that I can manage the plug-ins. The method is as follows:
Download the required hibernatgatels http://www.hibernate.org/6.html.
Decompress the downloaded file to get the features and plugins folders, create the addplugins folder in the eclipse installation directory, create the hibernatetools folder under the addplugins folder, and set the two folders (features and plugins) copy to the hibernatetools directory, create the links folder under the eclipse directory, and create the hibernatetools folder under the links folder. link file to open the file and enter the absolute directory of hibernatgatels.
My folder is as follows:
D: \ Java \ plateform \ eclipse_jee \ eclipse \ addplugins \ hibernatetools
D: \ Java \ plateform \ eclipse_jee \ eclipse \ links
The content of the hibernatgatels. Link file in the links folder is as follows:
Path = D:/Java/plateform/eclipse_jee/Eclipse/addplugins/hibernatetools
Restart eclipse.
Create a project myhibernate, and then select File-New-hibernate configuration file (CFG. XML), open the create hibernate Configuration Wizard, I have configured an SQL Server2000 Database here, select the "Create a console configuration" option, and create the hibernate console configuration in this configuration file.
500) This. width = 500; "border =" 0 ">
The create hibernate console Configuration Wizard has five tabs: Main, option, classpath, mappings, and common. If you have introduced the JDBC driver in the project, click Finish, other configurations will be completed later.
500) This. width = 500; "border =" 0 ">
After the configuration is complete, you can see the configuration item in the hibernate configuration View window, which has been linked to the data and columns in your database. If you have not succeeded in this step, check whether you have installed the hibernate tools and jboos tools correctly. If you cannot find the JDBC driver, it means that the classpath of your project does not contain the JDBC driver jar package, load the correct driver.
500) This. width = 500; "border =" 0 "width =" 500 ">
If you cannot see the hibernate comprehensions window shown, it means that you have not opened this view, select windows-show view-other, and then select hibernate comprehenations to open this window. The position of the window does not matter, put him there as you like.
500) This. width = 500; "border =" 0 ">
The following describes how to use hibernate code generation to generate database table ing Java objects. First, create a table in the database and set the field name and primary key (primary key is very important, we recommend that you use a business-independent ID as the primary key for primary key selection.) Open the hibernate view and find the hibernate code generation mappings under the hibernate runtime icon, if this icon is not found, it is not in the hibernate view.
500) This. width = 500; "border =" 0 "width =" 500 ">
Configure a new configuration item, enter the configuration item name myhibernatecode, and select hibernate configuration (that is, the configured hibernate console configuration ), enter the reverse code output directory in the output directory (note that this directory generally only requires the project's source code SRC), and then check reverse engineer from JDBC connection, enter the package name (which package you want to store in SRC) in the package, and click setup-create new to open the reverse engineer Configuration Wizard, select the storage location for configuration (I put it under the src directory), and finally select the table for reverse engineering ,;
500) This. width = 500; "border =" 0 "width =" 500 ">
If no project exists in your database schema, check whether the console configuration you selected is correct. Click "refresh" and return,
500) This. width = 500; "border =" 0 "width =" 500 ">
Click the exporters tab and select the export project. The domain code (. java) and hibernate XML mappings (. HBM. XML), because the JDK version is relatively high, check the use Java 5 syntax item. Do not set refresh and common items, and click Run to generate code.
500) This. width = 500; "border =" 0 "width =" 500 ">
The generated code and configuration files are displayed. After the code is automatically generated, you need to check the code based on your business logic and follow your Dao architecture, hibernate tools has completed a lot of coding work for you.