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
context.
John-
On Tue, Mar 30, 2010 at 2:20 PM, Michael Gentry <mgentr..asslight.net>wrote:
> 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, <MGargan..scholar.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
> >
>
This archive was generated by hypermail 2.0.0 : Tue Mar 30 2010 - 17:27:14 EDT