<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <property name="connection.url">jdbc:mysql://192.168.56.101:3306/hibernate</property> <mapping resource="com/gvace/domain/Employee.hbm.xml"/> </session-factory> </hibernate-configuration>
<mapping resource="com/gvace/domain/Employee.hbm.xml"/> for mapping to each *.hbm.xml file
Output query for debug:
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">
<property name="hbm2ddl.auto">update</property>
Variable values: validate | update | create | create-drop
So the list of possible options are,
- validate: validate the schema, makes no changes to the database.
- update: update the schema, alter or add column, never delete column
- create: creates the schema, destroying previous data, every time when app loads
- create-drop: drop the schema when session factory closed.
Session Range
<property name="hibernate.current_session_context_class"> thread</property>
hibernate.current_session_context_class: jta, thread, managed, custom.Class
<property name="hibernate.current_session_context_class"> thread</property>
hibernate.current_session_context_class: jta, thread, managed, custom.Class
jta: cross databases/hosts, remote server database
thread: local events only, for one single database
Character Encoding
<property name="hibernate.connection.CharSet">utf8</property><property name="hibernate.connection.characterEncoding">utf8</property>
<property name="hibernate.connection.useUnicode">true</property>