Hi Roger, It makes your code independent on J2EE and thus also testable outside
You understand exactly what I mean.
As for the reasons to use wrap CMP entity beans with DAOs. There are many:
of an application server which is a huge advantage. Also, it provides
a huge simplification of the domain model since it does not have
to deal with the intricacies of entity beans. It decouples the development of your domain model from that of the
database. In particular you can use an assembler to map a fine grain
domain model to a coarse grain model of entity beans. It provides more freedom in the design of your domain model. In
particular, simple things in a regular POJO domain moasidel such as
inheritance are difficult with entity beans.
I think I am going for a design with DAO + CMP for these reasons because I am using inheritance in my domain model. Looking on the internet for some tricks to see how to implement inheritance with entity beans, it is apparent that this is possible, but increases complexity, and in my opinion increases it too much.
By the way, I think there is growing consensus these days that entity beans are one of the shortcomings of J2EE. At work we are doing all new development using DAOs and Hibernate. DAO to be independent of the persistence mechanism and Hibernate for obtaining the easy mapping of a fine grain object model to a coarse grain data model, and to allow persistence also to be used outside of the container.
Doing the certification feels a bit like selling my soul, but it is possible to do a proper design with entity beans as well. If inheritance would have been easier with entity beans, then I could have simplified my submission by using CMP entity beans directly. Now because of these shortcomings, I have to introduce DAOs because otherwise the code would get too complex for my taste.