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