Doctype Hibernate-configuration 5

In Hibernate 5 it is necessary to use correct doctype hibernate-configuration 5.

Using Doctype in hibernate-configuration 5

In Hibernate 5 correct doctype should be used and this data is provided in the configuration file of Hibernate, the hibernate.cfg.xml file.

What is Doctype in Hibernat?

The DOCTYPE hibernate-configuration PUBLIC declaration which is done in hibernate.cfg.xml of Hibernate.

In this file we specify the dtd details to be used by Hibernate runtime.

Here is information about the doctype declaration:

  • DTD to be used - Its hibernate-configuration-5.0.dtd file in Hibernate 5.
     
  • In the configuration of file of Hibernate we also provide the Database Driver class name which is used connect to database.
     
  • Connection url - URL of the database server
     
  • User name: Database username
     
  • Password: Password of database
     
  • Hibernate dialect class - The database specific class in Hibernate.

After providing all these information Hibernate will be able to instantiate ORM system at application startup.

Example of hibernate.cfg file

In Hibernate 5 you should use correct dtd configuration. Following hibernate.cfg file shows how to include Hibernate 5 dtd correctly:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-5.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate5</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>

<mapping class="net.roseindia.model.Employee" />

</session-factory>
</hibernate-configuration>

So, you learned the correct way to configure dtd in Hibernate 5 application. Explore following tutorials of Hibernate 5:

Advertisements

 

We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.

Share on Google+Share on Google+

Doctype Hibernate-configuration 5

Posted on: October 26, 2017 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Doctype Hibernate-configuration 5  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads