This is an old thread, but still relevant to T5.1. I think Daniel is
completely right; the DefaultHibernateConfigurer always calls
Configuration.configure() which always sends Hibernate looking for
hibernate.cfg.xml. I know it's not too difficult to create your own
implementation of HibernateConfigurer and make it do what you want, but I
think at least the case where you just want to read from hibernate config
file with some other name is a fairly common scenario and the filename could
be just a property of DefaultHibernateConfigurer that by default returns
"hibernate.cfg.xml" but which you could set to a different value. I know at
least Kristian M. has worked on similar issues, what do people think, should
I open an enhancement request for it?

Kalle


On Thu, May 1, 2008 at 2:40 PM, Daniel Jue <teamp...@gmail.com> wrote:

> Has anyone else tried replacing the DefaultHibernateConfigurer?  I can
> add another configurator in my app module like this:
>
>        public static void contributeHibernateSessionSource(
>                        OrderedConfiguration<HibernateConfigurer> config,
>                        ClassNameLocator classNameLocator,
>                        HibernateEntityPackageManager packageManager) {
>                config.add("Default", new HibernateConfigurer() {
>                        public void
> configure(org.hibernate.cfg.Configuration arg0) {
>                                HibernateUtil.touch();// just in case this
> is the
>                                // first time it's been accessed.
>                                arg0 = HibernateUtil.getConfiguration();
>                        }
>                });
>        }
>
>
> but it doesn't actually replace the Default configuration.  I haven't
> looked but I guess the OrderedConfiguration is based on a List rather
> than a Map/Set.
>
> The org.hibernate.cfg.Configuration I want to use is completely set up
> programmatically.  It uses set properties and adds in annotated
> classes, and makes no use of any XML files.
>
>
>
> This is where the original default is added:
>
> public class HibernateModule
> ...
> 131        /**
> 132         * Adds the following configurers: <ul> <li>Default -
> performs default hibernate configuration</li> <li>PackageName
> 133         * - loads entities by package name</li> </ul>
> 134         */
> 135        public static void
> contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer>
> config,
> 136                                                            final
> ClassNameLocator classNameLocator,
> 137                                                            final
> HibernateEntityPackageManager packageManager)
> 138        {
> 139            config.add("Default", new DefaultHibernateConfigurer());
> 140            config.add("PackageName", new
> PackageNameHibernateConfigurer(packageManager, classNameLocator));
> 141        }
>
>
> The issue is Tapestry will call configuration.configure on
> DefaultHibernateConfigurer() which send hibernate looking for an xml
> file.
>
> I'd rather not have a fake hibernate.cfg.xml just to make it work.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to