You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@gmail.com> on 2010/05/13 13:22:46 UTC

tapestry-hibernate, supplement hibernate.cfg.xml with some code

hi all

i'm new to tapestry 5 and have started playing with tapestry-hibernate.

in other projects i've used an uncommon approach to configuring tapestry 
whereby i load most of the configuration via hibernate.cfg.xml, but then 
add a few more options via code and properties.

for example, the general config that doesn't change between different 
deployment targets is contained in the xml, but deployment specific 
values such as db url, username and password will come from a separate 
properties file and then provided to tapestry via Configuration.setProperty.

what's the simplest way to achieve something similar in tapestry 5.1 
with tapestry-hibernate?

thanks, paul.

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


Re: tapestry-hibernate, supplement hibernate.cfg.xml with some code

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 13 May 2010 16:48:07 -0300, Paul Stanton <pa...@mapshed.com.au>  
wrote:

> I assume you mean this bit:
>
> --quote
> Another way is to contribute objects that perform configuration (such as  
> setting event listeners). Example:
>
> public static void  
> contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer>  
> config)
> {
>   config.add("Widget", new WidgetHibernateConfigurer());
> }
> --end quote

Exactly!

> By adding, does that override the default configurer or just append to  
> do extras after the default has run?

It doesn't override, as configurers are run. Note that it is an  
OrderedConfiguration, so you can put your configurer to run before or  
after the other ones.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: tapestry-hibernate, supplement hibernate.cfg.xml with some code

Posted by Paul Stanton <pa...@mapshed.com.au>.
Thanks Thiago,

I assume you mean this bit:

--quote
Another way is to contribute objects that perform configuration (such as 
setting event listeners). Example:

public static void contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer> config)
{
  config.add("Widget", new WidgetHibernateConfigurer());
}
--end quote

By adding, does that override the default configurer or just append to do extras after the default has run?

Thanks, p.


Thiago H. de Paula Figueiredo wrote:
> On Thu, 13 May 2010 08:22:46 -0300, Paul Stanton 
> <pa...@gmail.com> wrote:
>
>> hi all
>
> Hi!
>
>> i'm new to tapestry 5 and have started playing with tapestry-hibernate.
>>
>> in other projects i've used an uncommon approach to configuring 
>> tapestry whereby i load most of the configuration via 
>> hibernate.cfg.xml, but then add a few more options via code and 
>> properties.
>>
>> for example, the general config that doesn't change between different 
>> deployment targets is contained in the xml, but deployment specific 
>> values such as db url, username and password will come from a 
>> separate properties file and then provided to tapestry via 
>> Configuration.setProperty.
>>
>> what's the simplest way to achieve something similar in tapestry 5.1 
>> with tapestry-hibernate?
>
> Contribute a HibernateConfigurer that does what you want: 
> http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html
>

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


Re: tapestry-hibernate, supplement hibernate.cfg.xml with some code

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 13 May 2010 08:22:46 -0300, Paul Stanton <pa...@gmail.com>  
wrote:

> hi all

Hi!

> i'm new to tapestry 5 and have started playing with tapestry-hibernate.
>
> in other projects i've used an uncommon approach to configuring tapestry  
> whereby i load most of the configuration via hibernate.cfg.xml, but then  
> add a few more options via code and properties.
>
> for example, the general config that doesn't change between different  
> deployment targets is contained in the xml, but deployment specific  
> values such as db url, username and password will come from a separate  
> properties file and then provided to tapestry via  
> Configuration.setProperty.
>
> what's the simplest way to achieve something similar in tapestry 5.1  
> with tapestry-hibernate?

Contribute a HibernateConfigurer that does what you want:  
http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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