Ygg01 / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
0 stars 0 forks source link

Consider adding HQL query helper methods... #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It might be nice to have these methods on our DAOImpl:
protected List executeQuery(String query)
protected List executeQuery(String query, Object... params)
protected Object executeQueryUnique(String query)
protected Object executeQueryUnique(String query, Object... params)

Why:
(1) This makes a little bit simpler interface than 
getSession().createQuery("some hql").list()

or

Query query = getSession().createQuery("some hql");
query.setParameter(0, "Holiday");
query.setParameter(1, "Bruce");
return query.list();

(2) These could help abstract developer changes to DAOs from the underlying 
technology. This way we could have an underlying Hibernate or EJB 
implementation with the same code on top of it. (Note: I'm not sure how 
helpful this really is.)

Why not:
(1) The developer may prefer to use criteria.
(2) It is only useful in limited situations because it limits a lot of the 
hibernate query functionality.
(3) It doesn't save that much code or make it that much more readable.
(4) It adds more code to be maintained in this project and ported to 
different implementations.

Original issue reported on code.google.com by dwolvert on 29 Oct 2008 at 2:58

GoogleCodeExporter commented 9 years ago
I've decided this is outside the scope of this framework for now. If anyone 
wants to 
add their own query helper methods, they have a very easy route to do so by 
extending 
the Generic and General DAO classes.

Original comment by dwolvert on 13 Mar 2009 at 4:44