Hibernate tool generates .hbm.xml and .java file

xiaoxiao2021-03-06  87

MySQL Database Table Generate Hibernate Profiles and Java Class Files are as follows: 1. Need packages: a. hibernate-2.1.6.zip b. hibernate-extensions-2.1.2.zip c. mysql-connection.jar 2. Specific Configuration: a. SetENV.BAT configuration is as follows: @echo off Rem ------------------------------------ ------------------------------ Rem Setup Environment for Hibernate Tools Rem ------------ -------------------------------------------------- ----- set JDBC_DRIVER = D: stonezhangProjectListeSaleseSalesPortalWEB-INFlibmysql-connector.jar set HIBERNATE_HOME = D: stonezhanghibernatehibernate-2.1.6hibernate-2.1 set cORELIB =% HIBERNATE_HOME% lib set lIB = .. lib set PROPS =% HIBERNATE_HOME% src set CP =% jdbc_driver%;% props%;% hibernate_home% hibernate2.jar;% corelib% commons-logging-1.0.4.jar;% Corelib% Commons-Collections- 2.1.jar;% CoreLib% Commons-Lang- 1.0.1.jar;% Corelib% cglib-full-2.0.2.jar;% Corelib% DOM4J-1.4.jar;% Corelib% odmg-3.0.jar;% Corelib% XML-Apis.jar;% CoreLib% XERCES -2.4.0.jar;% Corelib% Xalan-2.4.0.jar;% lib% jdom.jar;% lib% .. hibernate-tools.jar b. Hbm2java.bat configuration is as follows: <> @Echo off rem - --------------------- ------------------------------------------- Rem Execute HBM2JAVA TOOL REM -------------------------------------------------- ----------------- <> Call setENv.bat java-cp% CP% net.sf.hibernate.tool.hbm2java.codegenerator --output = H: EST H: Estcom TOLESALES * .XML where H: EST is the path to generate .java file, h: Estcom toLesales * .xml is the path to the XML file generated by DDL2HBM.BAT. 3. The operation is as follows: a. Will hibernate-2.1.6.zip And hibernate-extensions-2.1.2.zip is unzipped to a directory; b. Execute hibernate-extensions-2.1.2.zip to decompress the ToolsInsetenv.bat under the Directory, set environment variables; c. Perform hibernate-extensions-2.1. 2. Zip Decompression Directory Under the ToolSindDL2HBM.BAT, pop-up UI window, first configure the database connection parameters, click on the tables item, select the data table you need to generate .hbm.xml, you need to set keyword types in the mapping item, such as string Usually use "uuid.string", set the package name in the Code option and set the XML file output location in the Output item, and finally click "Generate"

转载请注明原文地址:https://www.9cbs.com/read-96590.html

New Post(0)