cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Дробеня Илья <droben...@tut.by>
Subject Re: Add ActiveRecord support to Cayenne
Date Tue, 18 Dec 2012 20:59:21 GMT
> You basically want to have entities persist themselves(curRole.save())?
I think instead of "save" we will use other method that flush context.
Maybe "commitContext". I agree that this will be very significant changes
if add separate commit for each entity.

> What is the problem with having a dependency on cayenne interfaces?
One of Ideas of DI - is separate different layers of application with
dependencies on each other. In our case all layers has dependency on
Persistent. It's not bad for many cases, but clear POJO - better. I agree
that (for example) JPA  entities has dependency on JPA annotations, but JPA
is just API and separates from persitence provider. Also annotations do not
impact on inheritance hierarchy. But I agree that current Cayenne solution
is good for many applications. But I think that will be good to allow user
to select pattern that he want to use (data mapper or active record).
Active record more simple to use - you do not need to inject in all places
context manager, you do not need to create DAO layer. And for many
applications active record will be good choice. For example, year ago I
develop call center software using Active Record - developers are happy.

>From my perspective - Active Record is good for RAD development,
prototyping, it's allow to use Cayenne through simple and useful API but he
adds more dependencies on Cayenne.

Also if we add this feature - it will be 2nd java persistence framework
that support it. And I believe - it will be best Active Recrod framework in
Java world.


2012/12/18 emeka okafor <emeka_1978@yahoo.com>

> Coming from EOF? I think those static helper classes are missing but it is
> not that bad either.
>
>
> ________________________________
>  From: John Huss <johnthuss@gmail.com>
> To: "user@cayenne.apache.org" <user@cayenne.apache.org>
> Sent: Tuesday, December 18, 2012 7:01 PM
> Subject: Re: Add ActiveRecord support to Cayenne
>
> I would welcome the addition of some DAO (data access object) methods in
> the entity templates that make it even easier to query the DB.  For example
> I have these defined in my entity template:
>
> public static List<Invoice> fetchAll(ObjectContext ec);
>
> public static List<Invoice> fetchAll(ObjectContext ec, List<? extends
> Ordering> sortOrderings);
>
> public static List<Invoice> fetch(ObjectContext ec, Expression qualifier);
>
> public static List<Invoice> fetch(ObjectContext ec, Expression qualifier,
> List<? extends Ordering> sortOrderings);
>
> public static List<Invoice> fetch(ObjectContext ec, Expression qualifier,
> List<? extends Ordering> sortOrderings, int fetchLimit);
>
> public static Invoice fetchOne(ObjectContext ec, Expression qualifier);
>
> This is something EOF/WebObjects does that I find useful.  However, I would
> lean towards creating an inner class for this along with a singleton called
> DAO and putting these methods there.  So you would do
> Invoice.DAO.fetchAll(...)
>
> But I don't really need .delete() or .save()
>
>
> On Mon, Dec 17, 2012 at 5:09 PM, Дробеня Илья <drobenyai@tut.by> wrote:
>
> > Hi!
> >
> > Now Cayenne usage in projects looks like data mapper (Fowler), but all
> > entities has dependecy on Cayenne (interface Persistent). For data mapper
> > it is disadvantage.
> > But it is acceptable for ActiveRecord. This is my first reason to propose
> > this solution. Second reason - we may simple add all posibile methods in
> > entities - because entities generates by modeler.
> >
> > Then my proposal - useful API that will be insert in each entity on
> > generation. For example, in this case we may use cayenne such -
> >
> > Role curRole = Role.newInstance();
> > curRole.setAuthority("MyAuthority");
> > curRole.save();
> >
> > Role curRole = Role.get(id);
> > curRole.delete();
> >
> > List<Role> roles = Role.findBy("firstName", name, "surname", lastName);
> > List<Role> roles = Role.findAll("birthDate < $date and name = $name",
> > "date", new Date(), "name", lastName);
> >
> > How we may to implement this?
> > Need to allow use Cayenne in classic mode without active record. Then we
> > may create separate set of templates and add its to Cayenne jars.
> >
> > Then for implement its we need:
> > 1. Create separate set of templates with needed methods
> > 2. Create singleton - that will provide access to ObjectContext
> > 3. Maybe add to modeler option for generate custom queries to entities
> > instead of add its to UntitledMap
> >
> > My questions to you:
> > 1. What do you think - do this functionality will really useful? Are you
> > ready to use it in your projects?
> > 2. Which methods you want to see in API?
> >
> > Thanks!
> > --
> > Ilya Drabenia
> > Software Engineer, ObjectStyle LLC
> >
>



-- 
С уважением, Илья Дробеня.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message