From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-09 03:53:23
|
>I'm new to Hibernate and have a simple question: Must Hibernate's >config file (not the mapping file, but the config/properties file) be in >the classpath? If not, how do I use it to configure Hibernate? >Hibernate.configure does not accept a URI and I don't see any other >methods that would do the trick. yes. There are two possible types of config files: (1) hibernate.properties (2) hibernate.cfg.xml Both of them are loaded as a resource from the classpath. hibernate.properties is automatically picked up and you don't need to do anything special to use it. ie. you dont need to call Hibernate.configure (). hibernate.cfg.xml is parsed and SessionFactory(s) are registered in JNDI upon the first invocation of Hibernate.configure(). If you are doing something more complicated, there are programmatic ways to do things. For example, (1) you can pass an instance of java.util.Properties do Datastore.buildSessionFactory() as an alternative to hibernate.properties. (2)You can instantiate your own instance of cirrus.hibernate.cfg.Configuration as an alternative to hibernate.cfg.xml / Hibernate.configure(). Hope that helps :) Gavin |