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