#36 Improvements to BMP DAOs

Andy Stevens
ejbdoclet (28)
Andy Stevens

I'm looking at improving the DAO stuff for BMP entity
beans, in particular, I'm thinking of making it work
more like the dataobjects. Specifically:

- adding a template and/or subtask for generating the
DAO interfaces (CustomerDAO.java in the samples), with
an @ejb:dao class level tag in the bean class to
control its generation. You then code the DB-specific
subclasses for these (CustomerExampleDAO.java),
inheriting from them. (to avoid compilation errors in
your subclasses when new dao methods are added,
perhaps the template should generate an abstract class
with empty methods (or ones that throw an SQL
exception) rather than an interface?

- in the BMP template, it can check for whether a DAO
is being used (similar to ifIsWithDataContainer) and
automatically add the calls to the DAO into the
generated ejbLoad etc. rather than having to code it
in the bean class like CustomerBMPBean.java does.

- the @ejb:dao tag can specify the env-entry to use
for looking up the actual class, so we don't need to
include getDAO() with an @ejb:dao-method tag in the
bean class.

- in fact, this means all mention of the dao can be
removed from the bean class. So you could then switch
from using BMPs with DAOs to CMP without changing any
code, just switch the tag to @ejb:bean type="CMP"

- and, ideally, it'll work with the "component
inheritence" so I can have all my entity EJBs inherit
from an abstract superclass, and using DAOs that
inherit from an abstract DAO (with the PK and findAll
finders being declared in the abstract DAO superclass).

Any comments/suggestions/improvements? (especially
from Vincent, since he checked in the existing bits)


  • Vincent Harcq
    Vincent Harcq

    Logged In: YES

    (I think my mail disappear)
    I think that if you can have the "one change only" to move
    cmp<-->bmp, it is perfect !

    But I also want to have some configurable access more
    general than DAO. Some methods implemented in a class in
    different ways and this class being defined through env
    entries. Depending of specific deployment I change the env-
    entry and bingo I have different behaviour.

    So the best is maybe you rename my stuff using ... I don't
    know ... and use the "dao" naming for your new stuffs.