cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Cayenne pattern quesiton
Date Tue, 30 Mar 2010 21:20:47 GMT
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 if you like:

http://cayenne.apache.org/doc/api/org/apache/cayenne/DataObjectUtils.html
(objectForPK)

Of course, this is just what I tend to do.  Your mileage and that of
others will likely vary.  To me, part of the concept of the DAO is
that you can transparently and magically change the DAO code to use a
different ORM and if everything else is using the DAOs, it'll all just
work.  Of course, the assumes that every single ORM works exactly the
same way (they don't) and it also means you are choosing your ORM for
failure (because you expect the need to swap them out).  Cayenne works
differently than Hibernate which works differently than other ORMs.  I
choose an ORM for the features it gives me.  To me it doesn't make as
much sense to code with the DAOs (especially when they limit the use
of your ORM), but I'm sure others will disagree with me.  :-)

mrg


On Tue, Mar 30, 2010 at 4:51 PM,  <MGargano@escholar.com> wrote:
> 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's to begin with so I'm not sure if it was just retrofitted to
> use DAO's with Cayenne.  I tried to look at some other examples from the
> website, but most of those are either not complex enough to warrant that
> kind of structure or the links are dead.  I hope this is clear.  :)  Also
> if DAO's are the recommended pattern to use is there a tool (i.e. eclipse
> plugin) that will generate them?
>
> Thanks.
> -Mike
>

Mime
View raw message