You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andy Buckley <An...@durham.ac.uk> on 2007/10/01 16:01:49 UTC

T5: Using external Hibernate-mapped entities: the "contribute" method goes where?

Hi,

I'm trying to get Tapestry working with Hibernate - unfortunately there isn't
much guidance on this, but I found this tutorial handy:

http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate

My application differs from this template, though, because the mapped entities
are in an external library. This page:

http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html

shows a way to deal with this, but I'm left with no idea where to put my
contributeHibernateSessionSource(...) method! It doesn't seem to work if added
to the page class (good: that would be inconvenient anyway!) so where should I
put it? Help! :-)

Thanks,
Andy

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


Re: T5: Using external Hibernate-mapped entities: the "contribute" method goes where?

Posted by Robin Helgelin <lo...@gmail.com>.
On 10/1/07, Andy Buckley <An...@durham.ac.uk> wrote:
> shows a way to deal with this, but I'm left with no idea where to put my
> contributeHibernateSessionSource(...) method! It doesn't seem to work if added
> to the page class (good: that would be inconvenient anyway!) so where should I
> put it? Help! :-)

In your AppModule-class or if it's defined as something else in your web.xml.

-- 
        regards,
        Robin

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


Re: T5: Using external Hibernate-mapped entities: the "contribute" method goes where?

Posted by Andy Buckley <An...@durham.ac.uk>.
Chris Lewis wrote:
> Your "AppModule" is created with the same name used in web.xml (as Robin
> pointed out). By default its AppModule.java, as created by the
> quickstart archetype. You should find that to use Hibernate you need
> only to add it, annotations, and tapestry-hibernate to your pom.xml.
> After that you need only to @Ineject Session instances into
> classes/components/pages where you want to use it. For the record, I did
> a test with entities in a different package (not *.entities) and was
> able to use Hibernate fine. This is because the tapestry-hibernate
> module auto-loads (and maganges) sessions based on hibernate.hbm.xml,
> which also is responsible for loading entities (unless you configure via
> another method). I did not need to contribute as the documentation
> suggested.

Thanks for your help: I'd forgotten that the archetype had made the "services"
directory. I had to comment out some references to
org.apache.tapestry.ioc.ServiceBinder which wouldn't compile, but otherwise
it's all good.

I think it didn't work automatically for me, since almost all of my Hibernate
configuration is done programmatically rather than via the hibernate.cfg.xml
file - but thanks for the suggestion anyway!

Cheers,
Andy

-- 
Andy Buckley: CEDAR @ IPPP, Durham
Work: www.cedar.ac.uk
www.insectnation.org

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


Re: T5: Using external Hibernate-mapped entities: the "contribute" method goes where?

Posted by Chris Lewis <ch...@bellsouth.net>.
Your "AppModule" is created with the same name used in web.xml (as Robin 
pointed out). By default its AppModule.java, as created by the 
quickstart archetype. You should find that to use Hibernate you need 
only to add it, annotations, and tapestry-hibernate to your pom.xml. 
After that you need only to @Ineject Session instances into 
classes/components/pages where you want to use it. For the record, I did 
a test with entities in a different package (not *.entities) and was 
able to use Hibernate fine. This is because the tapestry-hibernate 
module auto-loads (and maganges) sessions based on hibernate.hbm.xml, 
which also is responsible for loading entities (unless you configure via 
another method). I did not need to contribute as the documentation 
suggested.

sincerely,
chris

Andy Buckley wrote:
> Hi,
>
> I'm trying to get Tapestry working with Hibernate - unfortunately there isn't
> much guidance on this, but I found this tutorial handy:
>
> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate
>
> My application differs from this template, though, because the mapped entities
> are in an external library. This page:
>
> http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html
>
> shows a way to deal with this, but I'm left with no idea where to put my
> contributeHibernateSessionSource(...) method! It doesn't seem to work if added
> to the page class (good: that would be inconvenient anyway!) so where should I
> put it? Help! :-)
>
> Thanks,
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


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