>Based on what you described, i can't really see how hibernate would work
>with multiple datasources in a j2ee environment (which i think is really
>important: the reasons for using J2EE are less, if you dont have to
>juggle multiple datasources, etc).
For multiple datasources, use multiple instances of SessionFactory. Each
instance of SessionFactory may be configured using a different set of
properties by using
Datastore datastore = Hibernate.createDatastore()........;
Properties props = .... ;
SessionFactory sf = datastore.buildSessionFactory(props);
>It seems to me that putting the JNDI binding stuff in hibernate is
>probably a bad idea, _especially_ using VM level settings.
ie. they need not be VM-level settings. But in the common case of a
single database they _can_ be.
> - and just put a resource ref (or env-ref?) in the beans' descriptor
>pointing to the sessionfactory it's going to use (or more, if you happen
>to need more in the same bean)
Thats the intended usage. You couldn't do that before because the
SessionFactory didn't implement javax.naming.Referenceable.
>of course, nothing prevents me from doing this anyway, i guess :)
As currently implemented, you wouldn't be able to bind the SessionFactory
yourself, because the instance is only registered with a
javax.naming.spi.ObjectFactory if a session_factory_name is specified.
I could change this so that every instance is registered with the
ObjectFactory class and then its the application's reponsibility to bind it
to the name server. However, I can't really see that this provides that
much extra flexibility......
> but in
>what you described i don't really see the point in having all these jndi
>features in the hibernate core. what i really like about hibernate so
>far, is that it tries to do only one thing, and does that in an elegant
>fashion. i think the jndi stuff is just bloat, that in a simple case you
>don't need, in a complex case you can't use.
I think you can still use it in the complex case you describe. I think it
_would_ be bloat if it would have taken me more than a few lines of code to
implement or if you would be forced to use this functionality, which you
certainly _aren't_.
I appreciate your input.....
peace
Gavin
|