Christian,
I see that you removed parametrization by ID class.
It makes this impementation very limited since most
in real-world application ID types will be different for different
entities. I understand in your application they all are Long,
but for most of people it will limit reusability of this code.
In my example there also was restiction on persitentClass
that it has to implement Serializable, which is the case here.
GenericHibernateDAO<T extends Serializable, K extends Serializable>
GenericHibernateDAO should not let you create a DAO to a class
which is not Serializable.
Another note regarding
Code:
public List<T> get(Criterion... criterion)
method in GenericHibernateDAO.
The point of this method is not to expose it to business layer, but
rather to have it there for implemeting (business oriented) finders in HibernateDAOs
such as ItemDAOHibernate, CategoryDAOHibernate.
So I think it would be better if you leave it uncommented,
but make it protected instead of public.
You can even have methods like this one for CategoryDAOHibernate.
Code:
public List<Category> getRootCategories() {
return get(Expression.isNull("parentCategory"));
}
to illustrate using of List<T> get(Criterion... criterion)
You now implemented abstract Factory pattern for DAO, but
you client code (command) layer is not using it yet.
(It might be that I just to not see latest CVS commits on a cvsweb).
Current implementation looks much nicer.
I hope that you could integrate my comments too.
When all this compiles and runs it should be quite nice DAO implementation, which many people could benefit from. Thank you.
Regards,
--Mikhail