How to use hibernate.properties file instead of hibernate.cfg.xml

后端 未结 4 1583
清酒与你
清酒与你 2021-02-13 00:36

I am trying to connect to DB in a servlet using Hibernate.I have read that we can use either hibernate.cfg.xml or hibernate.properties file for configuration of session.For me i

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-13 01:04

    From what i understood from hibernate the best thing to do is to define the mapping in the hibernate.cfg.xml file and other configurations in the hibernate.properties.

    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.

    The hibernate.cfg.xml is also more convenient once you have to tune the Hibernate cache. It is your choice to use either hibernate.properties or hibernate.cfg.xml. Both are equivalent.

    You can read more about this in the following link:

    http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

提交回复
热议问题