I think this makes sense, and I definately have a use for it.  I've
implemented more or less the same thing at the web application level where
with a ServletContext Listener that  listens for the ServletContextCreated
event and creates a SessionFactory and stores it in the application scope.

With this in place, I would no longer need this code, and I could share the
SessionFactory between the instances of the web application.

----- Original Message -----
From: <Gavin_King/[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 12, 2002 9:40 AM
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

Reply via email to