+1 to Rob. You are absolutely right on the pattern you describe. One of the main reasons is that you want to have repeated patterns throughout your code even when your code becomes more complex.
When I am first starting, I will usually create a model and an Action and use a GenericManager, but unless you only need basic CRUD, then you are going to want to implement your own GenericManager. IMHO, the time spent doing some extra typing during development is a mere fraction of the time it takes to reverse engineer code that doesn't follow established good patterns. I have started to create all the Struts actions using a REST pattern and I am very happy with the results. Everything seems to fit nicely and everything "looks" the same so its easy to know where to look for certain functions if you are maintaining. -D Rob Hills wrote: > > 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 > > -- View this message in context: http://www.nabble.com/Executing-Named-query-tp16222852s2369p16231199.html Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
