Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hibernate.properties vs hibernate.cfg.xml

What is the order of precedence between hibernate.properties and hibernate.cfg.xml ?

For what I know hibernate.cfg.xml (if exists in the app's classpath) overrides hibernate.properties. Is my assumption correct ?

Thank you

like image 361
Sergiu Avatar asked Jun 26 '11 14:06

Sergiu


People also ask

Can we have hibernate properties instead of hibernate cfg XML?

cfg. xml . This file can be used as a replacement for the hibernate. properties file or, if both are present, to override properties.

What is hibernate cfg XML?

Hibernate Configuration File(cfg file) is the file loaded into an hibernate application when working with hibernate. Hibernate uses this file to establish connection to the database server.It is an XML file which is used to define below information. Standard name for this file is hibernate.

Is it necessary to use hibernate cfg XML for configuration in hibernate?

Hibernate also requires a set of configuration settings related to database and other related parameters. All such information is usually supplied as a standard Java properties file called hibernate. properties, or as an XML file named hibernate. cfg.

What happens when both hibernate properties and hibernate cfg XML are in the classpath?

If both hibernate. properties and hibernate. cfg. xml files are present in the classpath then hibernate.


1 Answers

From the documentation:

An alternative approach to configuration is to specify a full configuration in a file named hibernate.cfg.xml. This file can be used as a replacement for the hibernate.properties file or, if both are present, to override properties.

like image 80
Bozho Avatar answered Oct 20 '22 14:10

Bozho