Processing math: 100%

Tuesday, July 21, 2020

basic setup for hibernate

For hiberante.cfg.xml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.hbm2ddl.auto">update</property>
        <!-- JDBC Database connection settings -->
        <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://192.168.99.100:3306/JDBC_test?useSSL=false</property>
        <property name="connection.username">root</property>
        <property name="connection.password">cclee12345@12345</property>
 
        <!-- JDBC connection pool settings ... using built-in test pool -->
        <property name="connection.pool_size">1</property>
 
        <!-- Select our SQL dialect -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL55Dialect</property>
 
        <!-- Echo the SQL to stdout -->
        <property name="show_sql">true</property>
 
  <!-- Set the current session context -->
  <property name="current_session_context_class">thread</property>
        <property name="hibernate.hbm2ddl.auto">create-drop</property>
 
        <mapping class="com.machingclee.hibernatetutorial.models.Student">
    </mapping></session-factory>
</hibernate-configuration>
and pom.xml we need:
1
2
3
4
5
<dependency>
  <groupid>mysql</groupid>
  <artifactid>mysql-connector-java</artifactid>
  <version>8.0.20</version>
</dependency>
in additional to the hibernate maven dependencies.

No comments:

Post a Comment