Web project Configuration Hirbernate

Source: Internet
Author: User

1: First Find hibernate-release-4.1.9.final.zip\hibernate-release-4.1.9.final\lib\required, Copy all the jar packages in the required into the Lib package under Web-inf, and then put the Odbc.jar package that accesses the database into LIB.

2: Add Hibernate.cfg.xml file (under SRC). Copy the ready-made Hibernate.cfg.xml file under Hibernate-release-4.1.9.final.zip\hibernate-release-4.1.9.final\project\etc.

Then delete the file with the Red line:

<session-factory name= "foo" ;
  <property name= "Show_sql" >TRUE</PROPERTY>
  <mapping resource= "Org/hibernate/test/legacy/simple.hbm.xml"/>
  <class-cache
    class= "Org.hibernate.test.legacy.Simple"
   region= "Simple"
   usage= "Read-write"/>
 </session-factory>

3: After creating the package name and the entity class, the configuration map file is generally named "entity class name. hbm.xml" as the file name. And then find the Web App Libraries under the Hibernate-core-4.1.9.final.jar point open and then open the first package org.hibernate then find the penultimate file (HIBERNATE-MAPPING-3.0.DTD), double-click after the copy inside the <! DOCTYPE hibernate-mapping Public
"-//hibernate/hibernate Mapping DTD 3.0//en"
"Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > <?xml version= "1.0" encoding= "UTF-8"?> to the mapping file. Then simply configure it as:

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE hibernate-mapping Public
"-//hibernate/hibernate Mapping DTD 3.0//en"
"Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
<class name= "Cn.jnti.bean.county" table= "T_county" >--entity class name corresponding table name
<id name= "id" >--PRIMARY key column
<generator class= "sequence" ></generator>--oracle auto-Generate sequence
</id>
<property name= "CNAME" ></property>--attribute corresponding column name
</class>

4: Again to configure the Hibernate.cfg.xml file,

Complete.

Web project Configuration Hirbernate

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.