Use SQL Server to configure middlegen and extensions to generate HBM and pojo

Source: Internet
Author: User
Tags mssqlserver
To SQL Server Configuration Middlegen And Extensions Generate HBM And PojoAuthor: Yang Xiao (http://blog.sina.com.cn/u/1237288325) 1, the use of software and its version is as follows: ant-1.6.5Middlegen-Hibernate-r5hibernate-extensions-2.1hibernate-2.1.6 and above are decompressed to d Disk 2, configure ant to test D: root directory
Add ant_home = D: // antpath = D: // ant // bin to the environment variable;
Enter ant in the doscommand line. If the following prompt is displayed, it indicates that ant has been configured successfully: buildfile: Build. XML does not exist!
Build failed 3. Configure middlegen-hibernate: 3.1 configure MSSQL. XML file, which is used to configure the SQL Server database connection. jar; msbase. jar; msutil. jar) copy to Middlegen-Hibernate-r5/lib directory. There is an MSSQL. xml file in the Middlegen-Hibernate-r5/config/database directory that is used to configure the connection to the SQL Server database. The content is modified as follows (the red part is changed): <property name = "database. script. file "value =" $ {SRC. dir}/SQL/$ {name}-MSSQL. SQL "/> <property name =" database. driver. file "value =" $ {Lib. dir}/MSSQLServer. jar "/> <property name =" database. driver "value =" com. microsoft. JDBC. sqlserver. sqlserverdriver "/> <! -The structure of the bold part is: // database server name or IP address; database = Name of the database to be operated --> <property name = "database. URL "value =" JDBC: Microsoft: sqlserver: // Localhost: 1433; databasename = northwind"/> <Property name =" database. userid "value =" admin "/> <property name =" database. Password "value =" admin "/> <! -- In ms SQL database. Schama is the owner of the tables as displayed by SQL Server Enterprise Manager --> <property name = "database. schema" value = "DBO"/> <! -- In ms SQL database. catalog is the name of database such as 'northwind '--> <property name = "database. catalog "value =" northwind "/> <property name =" JBoss. datasource. mapping "value =" Ms sqlserver "/> 3.2 configure the ant runtime file build for the Middlegen-Hibernate-r5. XML <! Doctype project [<! Entity Database System "file:./config/database/MSSQL. xml">]> specifies the database configuration file used. <Project name = "middlegen hibernate" default = "all" basedir = ". "> <property file =" $ {basedir}/build. properties "/> <property name =" name "value =" sample "/> indicates the generated *. HBM. XML output path: <property name = "build. gen-src.dir "value =" C:/sample "/> Configure hibernate: 5.1.2 ddl2hbm. bat is a database export table structure and generates a poing file and pojo. This function overlaps with middlegen functions and is not mature enough (in fact, it has been deprecated and will not be maintained );
5.1.3 hbm2java. bat generates the corresponding pojo Based on the ing file, that is, *. HBM. generate the corresponding *. java file 5.2 has a setenv in the hibernate-extensions-2.1.2/tools/bin directory. BAT file, change the content to: Set jdbc_driver = D:/Middlegen-Hibernate-r5/lib/MSSQLServer. jarset hibernate_home = .. /.. /hibernate-2.1.6set corelib = % hibernate_home %/libset Lib = .. /libset props = % hibernate_home %/srcset CP = % jdbc_driver %; % props %; % hibernate_home %/hibernate2.jar; % corelib %/commons-logging-1.0.4.jar; % corelib %/commons-collections-2.1.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 6, run hibernate-extensions, according to HBM. XML generates pojo files and runs hbm2java C:/sample/org/hibernate/sample/* in DOS /*. XML -- output = C:/sample/about the author:
YANG Xiao, master of computer science from Beijing Business University, once worked in Java Development in NEC-Si and softbrain.
Blog: http://blog.sina.com.cn/u/1237288325
MSN: South-Titan@hotmail.com

 

Related Article

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.