Best practice - use a combination of Tapestry and Hibernate "tricks".
Use separate configuration files, and pick to use based on the mode
you are running in your AppModule:

        public void 
contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer>
configurer,
                        @InjectService("DefaultHibernateConfigurer") 
HibernateConfigurer
defaultHibernateConfigurer) {

                class RunModeDependentHibernateConfigurer implements 
HibernateConfigurer {

                        public void configure(org.hibernate.cfg.Configuration 
configuration) {
                                if (productionMode ||
"true".equals(System.getProperty(Symbols.FORCE_PERSISTENT_DB)))
configuration
                                                
.configure("/hibernate-production.cfg.xml");
                                else 
configuration.configure("/hibernate-test.cfg.xml");
                        }
                }
                ;
                configurer.add(productionMode == true ? "production" : "test", 
new
RunModeDependentHibernateConfigurer(), "before:*");
        }

I had earlier (in bind()) set the static productionMode flag based on
the value of System.getProperty(SymbolConstants.PRODUCTION_MODE). We
also use another flag to force the persistent db even if we are
running in development mode (handy when you want to with the
production database).

Even if you don't understand the code, copy and paste it to your
AppModule and resolve errors and see how it behaves, then read the
documentation for tapestry-ioc and tapestry-hibernate modules.

Kalle


On Fri, Nov 13, 2009 at 9:46 AM, Alessandro Bottoni
<alexbott...@gmail.com> wrote:
> Hi All,
> I'm almost completely new to Tapestry and Hibernate so, please, be patient..
>
> In your opinion, what's the best (simplest/most-maintainable) way to
> deal with two different databases with T5 and H3?
>
> I have the classical stage/production environment with the same software
> (and the same RDBMS) on the two machines but two different data sets and
> I have to switch from the one to the other when deploying the T5 stuff.
>
> Is it better to rely on the mechanisms provided by Hibernate (loading
> different configuration files, for example) or is it better to use some
> Tapestry-specific trick?
>
> How do you do that, usually?
>
> Thanks in advance for your attention.
>
> --
>
> Alessandro Bottoni
> Website: http://www.alessandrobottoni.it/
>
> "In mathematics you don't understand things. You just get used to them."
>     -- John von Neumann
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to