Hi Derek,

Derek Broughton wrote:
Rob Hills wrote:

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.
Yes, and GenericManager does its DB stuff via GenericDao...
I think I have it, now.  It's trivial :-)

        WebApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(this.getRequest().getSession().getServletContext());
That may well work, but I suspect it's a bad habit to get into. Creating your own Manager (extending GenericManager) and Dao (extending GenericDao) and their implementing classes can be a bit of a chore, but unless your app is a _very_ simple one, I think the collective wisdom would be that following the MVC approach is worth the extra effort. If you've not seen it, the AppFuse Hibernate tutorial ( http://appfuse.org/display/APF/Using+Hibernate + subsequent pages) details how it all hangs together.
I use a number of named queries in my app,

So I saw when I was searching - did you ever solve your Boolean problem?

No, I ended up having to work around that one, I was never able to work out a query that would work.

Cheers,

Rob Hills

Reply via email to