Hibernate configuration!

xiaoxiao2021-03-06  53

1. First prepare the environment, the following Hibernate and its plug-in download address http://prdownloads.SourceForge.Net/Hibernate/?sort_by=date&sort=desc

Hibernate Middlegen-Hibernate Hibernate-Extions Ant http: //ant.apache.org jdbc for sqlserver2000

2.Hibernate basic code includes

Pojopojo should understand Domain Object.pojo corresponding to database tables in Hibernate is a normal Java object that "Plain Ordinary Java Object" is formatted. It can be understood as a value object that does not contain logic code (Value Object)

public class TUser implements Serializable {private String name; public User (String name) {this.name = name;} / ** default constructor * / public User () {} public String getName () {return this.name;} public Void setName (String name) {this.name = name;}} Hibernate mapping file Hibernate is an "object-relational data mapping" (OBJECT RELATIONALMAPPING) ORM. The front POJO is reflected here that the semantics of the Object layer in the ORM, and the mapping file is the link associated with the object (Object) with relational data, in Hibernate, mapping files usually ". HBM.XML "as a suffix.

3. By the database, the basic code Hibernate provides the Middle Gen for Hibernate and Hibernate_extension toolkit, which is easy to export the database table structure, generate ORM and POJO, based on existing databases. Here is an example.

4. Configure MiddleGen-Hibernate to C: / Work / MiddleGen.

5. Connect Hibernate to C: / Work / Hibernate.

6. Connectue EXTENTIONS to C: / WORK / EXTENTIONS

7. Enter the / config / database subdirectory of the MiddleGen directory. We use SQLServer2000 here, so choose MSSQL.xml

Open MSSQL.XML

Change here

After we install the downloaded JDBC for SQLServer2000, put the 3 JAR files below the installation directory / lib directory in the Lib Directory of MiddleGen.

// Drive JAR File " Use WinRAR to open the JAR file above the JAR file can see the path in the JAR file in the JAR file