EJB 2.0 and DAO

I am curious about the pros and cons of using DAO with CMP in an EJB 2.0 app server. It seems this would not be necessary ... Has anyone tried it? Is it even WORTH trying?Thanks,Tom
[216 byte] By [twinans] at [2007-9-26 2:51:31]
# 1

I would say it is not worth trying, as it runs counter to the principle goal of 2.0 CMP, which is to allow Entity development against an abstract schema.

With EJB 2.0, the Container has the responsiblities of the DAO, which allows your Entity beans to work with different databases and relational schemas without modification. Nirvana!

perisb at 2007-6-29 10:38:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Isn't that also true for EJB 1.1? DAO is really only used in BMP. Regardless of versions, CMP does the data access part for you, so you don't need to write DAO at all.
yilin at 2007-6-29 10:38:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
I don't think there is any direct application of DAO in CMP since the container has the direct interface with the database. Value objects however can be quite useful. You can encapsulate cohesive attributes in a value object and reduce the necessity of accessing the bean.
swatdba at 2007-6-29 10:38:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

The problem with value object is that from DB point of view, value objects is just a blob (of serialized java object), so you cannot store in a relational fashion (e.g. you can save, but you cannot do db query or finder method using value object).

Finally, note that DAO and value object are 2 different things. DAO handles database access while value object represents data in non-relational fashion.

yilin at 2007-6-29 10:38:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Never mind my last message, I was thinking about dependent value object, not value object. You know, dependent value object and value object are also 2 different things which similar names.
yilin at 2007-6-29 10:38:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...