Quote:
Intermixing business logic with Hibernate API calls is not a good design choice, IMO. DAOs serve a very useful purpose in isolating persistence (Hibernate) logic from business logic.
of course, use DAO. Just one example swithing from hibernate 2 to hibernate 3 need to change all hibernate imports. If you also want to take advantage of new features, using DAO helps you a lot: you know where to look at!
IMO, 1 DAO per POJO is too much, if you have a well packaged fined grained domain model, 1 DAO per package is good.
In my apps, generally only one package is necessary for a use case.
I mean, use-case *--1 package (in genaral, you can have reporting use-case that need pojo from many packages).
But this depends on the way you're designing your apps...
About architecture, i personaly use
JSP(view) 1--* Action(struts view controller) *--1 Business Delegate (delegation + business controller) *--* DAOInterface
I use DAO interface because some use case requires pure JDBC (because we just don't have money to rewrite them ;))
Stateless Session Beans are also ok.
I didn't want to add business control on the struts actions because it is clear to me that struts will be replaced (1 year maybe more) but that's only my POV.
Pojo are used on each layer of course.
For long application transaction i use a custom filter + hibernateUtils based on caveatemptor examples, i can switch between short and long session when i want.
For this, i'm using inheritance on business delegate (if businessDelegate is instance of longBusiness --> a long session is automatically with flushmode.NEVER and flush is called only at businessDelegate.commitApplicationTransaction(),... if not, we just use 1 session per http request and commit is called at the end of the filter).
Have in mind that application transaction don't have to be managed in the DAO layer, it's a business control problem.
Hope this helps.