Hibernate has gained popularity in the past few years as an add-on for Java EE and other applications. Its web site (www.hibernate.org) advertises this free product as "a powerful, ultra-high performance object/relational persistence and query service for Java." Using Hibernate, you do not need to implement your own persistence layer. Instead, you use a tool to create databases and related tables and determine how your objects should be persisted. Hibernate virtually supports all kinds of database servers in the market today, and its Hibernate Query Language provides "an elegant bridge between the object and relational worlds." More people will be using Hibernate in the near future. If you have time, invest in it.Of course, persistence is a huge topic to cover... but choosing to address only DAO while offering Hibernate one paragraph seems a little odd, especially considering the presence of JPA. In addition, some of the design choices of the DAO seem odd: one example is that JNDI lookups are considered an "expensive operation." Compared to what? The author caches the datasource, which eliminates the whole reason for using a Datasource in JNDI in the first place (live container management of the resource), and in tests, retrieving a datasource from JNDI isn't especially expensive... What's more, if the author had focused on Hibernate instead, it would have been a non-issue in the first place. Even with that, though, it's actually a very good and very useful book. Struts 2 is covered in enough detail that even new users can get up to speed in a fairly short time, with understanding of what's going on inside the framework. Examples are fairly clear, and illustrative of actual needs.
News: Book: Struts 2 Design and Programming
"Struts 2 Design and Programming" is a tutorial for Struts 2 by Budi Kurniawan. When it comes to the web application parts of Struts, it's very good and surprisingly thorough, but when it comes to other things, it's a little less well-informed. The book starts off by walking through Model 1 and Model 2 web development, introducing a short example of both designs. After that, you get chapter after chapter covering Struts from top to bottom, from the tags to FreeMarker to Velocity, OGNL to interceptors, security, file uploads and downloads, progress meters, custom result types, security... when it comes to Struts' core features, the book is quite good. However, there are a few oddities. Chapter 24 covers Tiles plugins, and while Tiles is certainly popular enough, the lack of coverage of SiteMesh – which does many of the same things, except with less intrusion. It's not so much that Tiles shouldn't have been covered, but choosing one while ignoring the other stood out some. The worst offender, though, is the persistence chapter, chapter 11. It focuses primarily on the DAO pattern, which isn't the worst pattern one could choose... but in a book printed in 2008, ignoring JPA and Spring seems a little out of place. Spring doesn't even get mentioned; Hibernate gets this:
- Posted by: Joseph Ottinger
- Posted on: March 14 2008 11:07 EDT
- Re: Book: Struts 2 Design and Programming by Michael Klaene on March 14 2008 12:17 EDT
- Re: Book: Struts 2 Design and Programming by James Watson on March 14 2008 14:17 EDT
- Effective Stripes-like development? by Jakub Exner on March 14 2008 17:47 EDT
I'd say the exclusion of Spring is very surprising, considering that Struts 2 utilizes Spring for DI.
I was under the impression that Struts 2 can also use Guice for DI.
I was under the impression that Struts 2 can also use Guice for DI.It can... but it uses Spring by default. For Struts developers used to wiring up to Spring in the 'traditional' way, Struts 2 makes it much easier since it will inject dependencies automatically in most cases. I would think the Struts+Spring+Hibernate approach is extremely popular so I too am surprised a Struts book of any kind wouldn't give that combo a little more attention. But especially Spring as Struts 2 and Spring are so intertwined.
The author caches the datasource, which eliminates the whole reason for using a Datasource in JNDI in the first place (live container management of the resource), and in tests, retrieving a datasource from JNDI isn't especially expensive...Isn't the whole point of a datasource to act as a proxy for retrieving resources? I'm not actually suggesting that you are incorrect here but it seems fairly ludicrous to not be able to cache a proxy. Considering that you can create datasources over datasources over datasources ... I see no reason why the user of a datasource must refresh it. Why can't the datasource hide that from the client? If it can't, it's almost a pointless abstraction and we might as well gets get DB connections from JNDI.
Hibernate is great and all but the idea that everything in Javaland must begin and end with Spring and Hibernate seems no different to me than the old zeitgeist that everything in Javaland revolved aroung EJBs.
What's more, if the author had focused on Hibernate instead, it would have been a non-issue in the first place.
Hibernate is great and all but the idea that everything in Javaland must begin and end with Spring and Hibernate seems no different to me than the old zeitgeist that everything in Javaland revolved aroung EJBs.I used to think same thing but every time I started 'simple' - without Spring and Hibernate I ended up spending more time adding just this or just that here and there and wished that I started with Spring + Hibernate default. Therefore today I say that it makes sense to start everything with Spring or Guice, then add Hibernate if project's database structure can be controlled or iBatis when dealing with given database. In the tiny minority of projects there is need to do something custom or fancy. Those frameworks do not add any complexity - they reduce it at the expense of bigger package, but these days transitive dependencies management provided by Ivy or Maven nearly eliminate any pain of managing collections of libraries and their versions.
Is it possible to be really effective developing webapps with Struts2, like it is with the Stripes framework? If yes, is there a tutorial or a demo app? I could not find anything good enough... the Struts2 documentation does not help very much, given that I want to develop a "good enough" application (internationalization, validations, etc.) using Struts2 with annotations fast.