Ways to configure Hibernate manually

Source: Internet
Author: User
Tags xml example

Preface: Have been accustomed to use myeclipse automatically generate hibernate, but the manual configuration has been not very understanding, are embarrassed to say that they are engaged in Java. So hurriedly reviewed the manual configuration, and recorded here, so often come back to see!

The first step: Build the environment

Download Hibernate-distribution-3.3.2.ga-dist.zip on Hibernate homepage (this is hard to find, be patient!) ), unzip the root directory of the Hibernate3.jar and required folder all the packages, database drive jar, copied to Web-info Lib.

Then build-path the jar that you just copied over the project.

Step Two: Build the map

First create the entity class (persisted Class) corresponding to the database table field, must implement the Java.io.Serializable interface

Then, under the same package for all entity classes, create the mapping file, as follows:

Hibernate configuration file XXX.cfg.xml Example:

<?xml version= "1.0" encoding= "Utf-8"? ><! DOCTYPE hibernate-mapping Public "-//hibernate/hibernate mapping DTD 3.0//en" "http://hibernate.sourceforge.net/ HIBERNATE-MAPPING-3.0.DTD "><!--mapping file autogenerated by MyEclipse persistence Tools--> Step Three: Configure the operating environment

In SRC, create the Hibernate profile XXX.cfg.xml, as follows:

<?xml version= ' 1.0 ' encoding= ' UTF-8 '? ><! DOCTYPE hibernate-configuration Public "-//hibernate/hibernate configuration DTD 3.0//en" "Http://hibern                   Ate.sourceforge.net/hibernate-configuration-3.0.dtd "><!--Generated by MyEclipse hibernate Tools. --> 

Ways to configure Hibernate manually

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.