ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: [VOTE] iBATIS for Java 2.2.0 promote to General Availability
Date Wed, 16 Aug 2006 16:06:28 GMT
Heh, calling employeeDao.delete(...) seems explicit to me. ;-)

It also lets me make them extend a common base dao that does all the work
for me:

===
public class CrudDaoImpl<Type, KeyType>
extends SqlMapClientTemplate
implements CrudDao<Type, KeyType> {

    protected String namespace;
    Logger log = Logger.getLogger(CrudDaoImpl.class);

    public CrudDaoImpl() {
        namespace = ((Class) ((ParameterizedType)getClass()
          .getGenericSuperclass())
          .getActualTypeArguments()[0]).getSimpleName();
        if (log.isDebugEnabled())
            log.debug("namespace for " + getClass() + " is " + namespace);
    }

    public Object insert(Type bean) {
        return insert(namespace + ".insert", bean);
    }

    public int update(Type bean) {
        return update(namespace + ".update", bean);
    }

    public int delete(Type bean) {
        return delete(namespace + ".delete", bean);
    }

...
}

===

Larry


On 8/16/06, Clinton Begin <clinton.begin@gmail.com> wrote:
>
>
> That will teach you for not naming your methods explicitly.  Delete?
> Delete what?  ;-)
>
> Good point though Larry.  If you design your DAOs to be very small and
> follow some convention like select, insert, update, delete....you might have
> this problem.  As a more general solution, I'd suggest just choosing
> different language like:  load, fetch, save, update, remove.
>
> That will avoid the whole problem.
>
> Cheers,
> Clinton
>
>
> On 8/16/06, Larry Meadors <lmeadors@apache.org > wrote:
> >
> > +1 with a warning to upgraders that almost got me.
> >
> > If you have a class defined like this:
> >
> > public class MyDaoImpl extends SqlMapDaoTemplate implements MyDao
> >
> > ...and a method like this:
> >
> > public void delete (String key)
> >
> > It won't compile until you rename your delete because it thinks you are
> > trying to override delete, and not returning and int value.
> >
> > This could be a bigger problem if your local delete method DOES return
> > int. Things that call delete(String mappedStatementName) won't behave quite
> > as expected, because they will call the overridden version instead.
> >
> > Larry
> >
> >
> >
> > On 8/15/06, Clinton Begin < clinton.begin@gmail.com> wrote:
> > >
> > >
> > > PMC Members,
> > >
> > > You've no doubt seen the 2.2.0 beta release email.  Unless you find
> > > any significant problems with the build, please now vote for iBATIS for Java
> > > 2.2.0 to be promoted to General Availabilty status.
> > >
> > > This vote will close Friday, August 18th.
> > >
> > > Best regards,
> > >
> > > Clinton
> > >
> >
> >
>

Mime
View raw message