were u thinking of leaving the option to configure programmatically in? the option to configure by file would definitely be usefull in some circumstances. most people r probably aware of the problems with this in the following scenario, but i'll babble on about it anyway. when deploying an application as some sort of archive (eg. war) and u have staging and live servers, u don't want to change the archive file between them (but the configuration is most likely different). so then the xml configuration file has to live outside the archive, which leaves the global classpath to the container. if u have multiple applications using hibernate in the container, u then need multiple configuration files - each file needs a different name and then how do u to tell hibernate to use the correct file for a particular app; or u need one configuration file that can contain the configuration for each application - hibernate still needs to be told which app it is dealing with.
ideally we want to have an application's configuration all in once place - including the configuration of third-party frameworks. to achieve this we have writen a wrapper/utility class for hibernate that (among other things) integrates with our application's configuration framework. all our code calls this utility class to get a session, which worries about configuration, etc. this is obviously not a solution for hibernate itself. at this stage i have not come up with any ideas that involve changing hibernate to improve the situation. brad > -----Original Message----- > From: Gavin_King/[EMAIL PROTECTED] > [mailto:Gavin_King/[EMAIL PROTECTED] > Sent: Wednesday, 12 June 2002 5:41 PM > To: [EMAIL PROTECTED] > Subject: [Hibernate-devel] XML SessionFactory configuration > > > > I've been thinking about the problem of configuring a > SessionFactory for > a J2EE application where application code has no control over > the system > initialization procedure. I'm thinking that instead of forcing the > application to do this programmatically, there could be a config file > like: > > <hibernate-configuration> > > <property name="show_sql">false</property> > <property name="use_outer_join">true</property> > <property name > ="jta.UserTransaction">java:comp/UserTransaction/</property> > > <session-factory name="/jndi/name"> > <property name="datasource">my/first/datasource</property> > <mapping resource="eg/Foo.hbm.xml"/> > <mapping resource="eg/Bar.hbm.xml"/> > </session-factory> > > <session-factory> > <property name="datasource">my/other/datasource</property> > <mapping file="C:/mapping/my_mappings.hbm.xml"/> > </session-factory> > > </hibernate-configuration> > > What I'm thinking of is that a call to > > Hibernate.configure() > > would look for a resource called hibernate.cfg.xml and use that to > configure and register SessionFactory(s) with JNDI. Subsequent > calls would do nothing. That way application components could all > call Hibernate.configure() when instantiated but we would guarantee > that the factories would only be initialized once. > > I dont want to see an explosion of configuration files but I think > this is reasonable. > > Opinions? Suggestions? > > I will check in some code sometime in the next couple of days for > people to play with.... > > Gavin. > > > _______________________________________________________________ > > Sponsored by: > ThinkGeek at http://www.ThinkGeek.com/ > _______________________________________________ > Hibernate-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > _______________________________________________________________ Sponsored by: ThinkGeek at http://www.ThinkGeek.com/ _______________________________________________ Hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel