idea of automatic Hibernate mapping file vo

 

From: https://blog.csdn.net/chenyunqiang/article/details/81026823

 

1, item and add items to build structural configuration and initial configuration parameters

1.1 The basic shelf as shown will build a good

 
 
1.2, click File, click the pop-up menu in the Project Structure;
 
 
1.3, click the Modules on the left side, then click on the "+" sign, and then in the pop-up menu, select Hibernate;
 
1.4, at this time, more of a project, Hibernate, click Hibernate, and then click on the "+" sign, select hibernate.hbm.xml;
 
1.5, the pop-up window, select the version of Hibernate, then click OK;
 
1.6, click OK Apply in the window of the original 1.4 step in the application to the girl by the project;
 
1.7, then the shelves in the project out of a configuration file called hibernate.hbm.xml of;
 
1.8, are arranged as follows hibernate.hbm.xml;
  1.  
    <?xml version=‘1.0’ encoding=‘utf-8’?>
  2.  
    <!DOCTYPE hibernate-configuration PUBLIC
  3.  
    “-//Hibernate/Hibernate Configuration DTD//EN”
  4.  
    “http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd”>
  5.  
    <hibernate-configuration>
  6.  
    <session-factory>
  7.  
    <! - Configuration database connection url ->
  8.  
    <property name=“connection.url”>jdbc:mysql://localhost:3306/SSHBlog?useUnicode=true&characterEncoding=utf8&useSSL=true&zeroDateTimeBehavior=convertToNull</property>
  9.  
    <!–数据库驱动配置–>
  10.  
    <property name=“connection.driver_class”>com.mysql.jdbc.Driver</property>
  11.  
    <!–数据库用户名配置–>
  12.  
    <property name=“connection.username”>root</property>
  13.  
    <!–数据库密码配置–>
  14.  
    <property name=“connection.password”></property>
  15.  
     
  16.  
    <!– DB schema will be updated if needed –>
  17.  
    <!– <property name=”hbm2ddl.auto”>update</property> –>
  18.  
    </session-factory>
  19.  
    </hibernate-configuration>
  • 1

1.9, the first step configured.

2, the configuration database

2.1, clicking on the left button, so that the window pattern shown in FIG;
 
2.2, select the database;
 
2.4 After configuring the database to test whether the connection is successful, and click OK on success;
 
2.5, as database;

3, Hibernate entity classes and generating profile

3.1, click on the window Persistence;
 
3.2, right in the Persistence project, and then click Generate Persistence Mapping, select By Database Schema;
 
3.3, select a data source, the configuration package entity class, the entity type selection to be generated (where the date of type java.util.Date only be modified manually), and then click OK;
 
3.4, after waiting for some time, we found the project entity classes and configuration files have been automatically generated.

Guess you like

Origin www.cnblogs.com/268lwc/p/11717629.html