> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Ben Litchfield > Sent: Saturday, January 22, 2005 1:03 PM > To: middlegen-user@lists.sourceforge.net > Subject: Re: [Middlegen-user] hibernateDAO failing to > generate findBy method for primary key > > ... I would love to hear some more comments on the > hibernateDAO> piece > > My goal is not not have every possible combination of methods > generated, but if we could get like 70%(save/delete/findByPK, findBySingleColumn) > > What else would you like to see?
pm4jih, i have not used middlegen for a while (and that was just to reverse). But was trying to learn how to write dao's. I ended up with a pair of inerfaces (please see below). I am a newbie to this stuff, and all of this will have problems trying to be abstracted above hibernate in to dao (for spring) and I'm sure it contains more than your 70% goal. This was for a real anemic domain model (1 pojo - 1 table), so take it with a grain of salt. But it does seem like mostly boilerplate and helper methods, so maybe some of methods might be candidates for your 70%. thanks package dsl.hibernate; import java.io.Serializable; import java.util.List; import net.sf.hibernate.HibernateException; import net.sf.hibernate.type.Type; public interface HTableDAO extends HDAO { List findField(final String fieldReference) throws HibernateException; List findByMatchingStringField(final String fieldReference,final Object value) throws HibernateException; List findByMatchingField(final String fieldReference,final Object value,final Type type) throws HibernateException; List findFieldAndPk(final String feldReference,final Serializable key) throws HibernateException; int deleteByKey(final Integer key) throws HibernateException; int deleteAll() throws HibernateException; List findAll() throws HibernateException; List findAllKeys() throws HibernateException; } package dsl.hibernate; import java.io.Serializable; import java.util.*; import net.sf.hibernate.*; import net.sf.hibernate.type.Type; public interface HDAO { String keyFieldReference(); Type keyFieldType(); Object load(final Object object,final Serializable key) throws HibernateException; Object get(final Class clazz,final Serializable key) throws HibernateException; Object load(final Class clazz,final Serializable key) throws HibernateException; int size(final net.sf.hibernate.Session session,final Collection collection) throws HibernateException; void save(Object object) throws HibernateException; void update(Object object) throws HibernateException; void save(Collection c) throws HibernateException; List find(final String hql) throws HibernateException; List find(final String hql,final Object value,final Type type) throws HibernateException; List findFieldAndPk(final Class clazz,final String feldReference,final Serializable key) throws HibernateException; List find(final String hql,final Object[] value,final Type[] type) throws HibernateException; void delete(Object object) throws HibernateException; void delete(Collection c) throws HibernateException; int delete(final String hql) throws HibernateException; int delete(final String hql,final Object value,final Type type) throws HibernateException; int deleteByKey(final Class clazz,final Serializable key) throws HibernateException; int delete(final String hql,final Object[] value,final Type[] type) throws HibernateException; int deleteAll(final Class clazz) throws HibernateException; List findFieldValues(final String fieldReference,final Class clazz) throws HibernateException; List findByMatchingStringField(final Class clazz,final String fieldReference,final Object value) throws HibernateException; List findByMatchingField(final Class clazz,final String fieldReference,final Object value,final Type type) throws HibernateException; List findAll(final Class clazz) throws HibernateException; List findAllKeys(final Class clazz) throws HibernateException; Serializable lastKey(final List keys) throws Exception; Serializable newKey(final List keys) throws Exception; List getKeys(final Class clazz); List setKeys(final Class clazz,final List keys); Hib h(); } ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ middlegen-user mailing list middlegen-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/middlegen-user