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;
-
-
-
-
-
<hibernate-configuration>
-
<session-factory>
-
<! - Configuration database connection url ->
-
<property name=“connection.url”>jdbc:mysql://localhost:3306/SSHBlog?useUnicode=true&characterEncoding=utf8&useSSL=true&zeroDateTimeBehavior=convertToNull</property>
-
<!–数据库驱动配置–>
-
<property name=“connection.driver_class”>com.mysql.jdbc.Driver</property>
-
<!–数据库用户名配置–>
-
<property name=“connection.username”>root</property>
-
<!–数据库密码配置–>
-
<property name=“connection.password”></property>
-
-
<!– DB schema will be updated if needed –>
-
<!– <property name=”hbm2ddl.auto”>update</property> –>
-
</session-factory>
-
</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.