Академический Документы
Профессиональный Документы
Культура Документы
2. xml file.
2. BY XML file.
3. Programmetic Approach.
1. First Approach:
Standard file name : hibernate.properties
hibernate.properties :
hibernate.driver_class=
hibernate.url=
hibernate.username=
hibernate.password=
In properties file, we can not configure mapping resources information (only configuration
information).
We need to add the mapping info programmetically :
Configuration configuration =new Configuration().configure();
----configure() method search for Hibernate.cfg.xml file in classpath (search
only for xml file not properties file).
Lines of code will be increased. A new file has been added, change the code.
2. Second Approach:
It is recommended to use xml file (Hibernate.cfg.xml placed in classpath)
Configuration configuration =new Configuration().configure();
----configure() method search for Hibernate.cfg.xml file in classpath(src
directory).
If the configuration file is not in src directory, it is in subdirectory of src directory then :
Configuration configuration =new Configuration().configure("path");
2. If you are just developing a simple application for experimental shake then you need to
go for properties file rather than writing the xml file.