I agree. My favorite method is to use Domain Driven Design techniques.
From: Malcolm Edgar
To: user
Sent: Thu, April 1, 2010 6:32:05 AM
Subject: Re: Cayenne pattern quesiton
I would argue against putting finder methods in the generated
entities, as I think
I would argue against putting finder methods in the generated
entities, as I think it is a separate concern and you can easily end
up with tightly coupled code which is difficult to refactor.
The "Rich Domain" model can end up becoming the "Blob" anti-pattern.
I don't think stateful entities obje
Also I suspect I am not using a classic version of DAO. My DAO's are
morphed with the "business layer" and can have interactions with other
subsystems, not just Cayenne (e.g. caching, data access via web
services, etc.). Also they are not auto-generated, as any new methods
are created when
I am using a form of DAOs (with injection) with the main reason being
that I can provide alternative implementations in a context-sensitive
manner without changing the DAO interface (something that can't be
done with the static methods), which is very handy in numerous
situations.
Andrus
I used DAOs in my last set of Cayenne projects, and other than dealing
with injecting the DAO into the methods needing them, it worked really
well. I went with a central ServiceLocator pattern to a DAOFactory to
deal with that situation as we had no IoC providers.
I used templates to generate 90%
Daos can be useful in certain contexts. In particular, if you have
some means of automagically generating the dao. :)
For instance, on a Tapestry5 + hibernate-based project I'm working on
right now, there's a DaoSource service.
What's more, is there's an @InjectDao annotation that plays nicely
My latest project has a lot of DAO going on and while it made sense (for
some reason, habit?) at first I regret going that way and will, over time,
be migrating into the same pattern that Michael highlights. Its really just
a big useless layer for all the reasons he highlights, at least in my
conte
Hi Mike,
I personally tend to not create DAOs for Cayenne. If I need a findBy*
type method, I just add it to the Cayenne-generated class as a static
method. (For example, I have a User.withUsernameAndPassword() static
method in my User class.) For findById, you can use DataObjectUtils
directly
When using Cayenne are DAO's still the pattern used for findAll,
findByProperty, and findById query methods or is there some better way to
do this in Cayenne? For example in the pet store project I see DAO's
being implemented, but I know that example was taken from other projects
that use DAO'