Rob Hills wrote:
> Hi Derek,
>
> Derek Broughton wrote:
>> Appfuse 2.0, Struts basic, Postgres
>>
>> I want to execute a Hibernate NamedQuery, but I can't figure out how to
>> get the hibernate Session from within my Action.
>>
>> Can somebody point me to some useful documentation - every example I've
>> found assumes you already have the Session.
>>
> I think your problem is that you should be doing that in your DAO, not
> your Action.
It's all autogenerated, with generic beans all over the place - I don't
_have_ a DAO. The first time I did this, before appfuse:gen existed, I had
DAOs, now the Action calls GenericManager.
I think I have it, now. It's trivial :-)
WebApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(this.getRequest().getSession().getServletContext());
SessionFactory sessionFactory =
(SessionFactory)ctx.getBean("sessionFactory");
SessionHolder sessionHolder =
(SessionHolder)TransactionSynchronizationManager.getResource(sessionFactory);
Session currentSession = null;
if (sessionHolder!=null) {
currentSession = sessionHolder.getSession();
}
> I use a number of named queries in my app,
So I saw when I was searching - did you ever solve your Boolean problem?
--
derek
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]