I am not sure exactly what it is that you are trying to achieve. You basically 
want to have entities persist themselves(curRole.save())? How do you for 
example want to track changes then? What is the problem with having a 
dependency on cayenne interfaces? I thought that the generated code is clearly 
separated from your domain objects. It's called "generation gap" I think. To be 
honest, even when I was still doing the JEE stuff, I always thought that POJO + 
annotations + dependeny injection were overrated. That's the reason why I came 
back to cayenne, after having done EOF at some point in my life.
Let the discussion start 


________________________________
 From: Дробеня Илья <droben...@tut.by>
To: user@cayenne.apache.org 
Sent: Tuesday, December 18, 2012 12:09 AM
Subject: Add ActiveRecord support to Cayenne
 
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

Reply via email to