I find I seldom need to have the SessionFactory exposed because most of my
transaction stuff is managed in Spring. I've moved a couple of services out
of Tapestry into Spring to do that as well. However, I've also cheated
before by exposing the SessionFactory in a DAO when I just needed to "get it
done".  Smelly, but I've held my nose once or twice.

You will see explicit references to the SessionFactory bean being used for
the transaction manager, and for the dao.  Is that what you meant about how
to get references to the SessionFactories?

You could also create different Spring beans whose sole purpose is to hold a
reference to a specific SessionFactory.  So, then you wind up injecting
FirstDatabaseSessionFactory and SecondDatabaseSessionFactory into Tapestry
pages and services.

Someone did post once, but I don't recall where, a Tapestry service override
that enabled injection of Spring beans by id.  That would be the cleanest
way if you found it.


I hope that helps.

JB


On Sun, Dec 5, 2010 at 4:32 AM, <tapes...@digiatlas.org> wrote:

> Thank you very much Jonathan,
>
>
>  It looks like you're using tapestry-hibernate as well as tapestry-spring.
>>  I've done a bunch of 2+ database stuff using tapestry-spring + hibernate,
>> and I've done single-db stuff using tapestry-hibernate, but I've never
>> mixed
>> hibernate configuration methods.
>>
>
> Neither had I - but I made the fatal mistake of not removing the
> tapestry-hibernate jars from my project and POM. Thank you for providing the
> hint!
>
>
>
>> Get rid of tapestry-hibernate.
>>
>
>
>  Your basic hibernate setup in Spring is fine.  Do the second the same way.
>> You will need to explicitly wire in your SessionFactories, rather than
>> rely
>> on auto-wiring.  A template helps out (sample to follow) .
>>
>
> Thanks for this.
>
>
>
>  You will not be able to @Inject your SessionFactories directly into
>> Tapestry
>> pages or services (duplicate service error).
>>
>
> Ok, so how can I access my session factories if I can't inject them?
>
> Where can I obtain the session factory instance - I'm afraid my knowledge
> of Spring is not very good.
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Jonathan Barker
ITStrategic

Reply via email to