ROR ActiveRecord like interface for Apache Cayenne 
---------------------------------------------------

                 Key: CAY-877
                 URL: https://issues.apache.org/cayenne/browse/CAY-877
             Project: Cayenne
          Issue Type: New Feature
    Affects Versions: 2.0 [STABLE]
            Reporter: David Marko
            Assignee: Andrus Adamchik
            Priority: Minor


ROR ActiveRecord  like interface for Cayenne. Solution tries to bring 
alternative syntax for working with Apache Cayenne subsystem. Though its 
working its still subject of discussion and improvement. My idea is not to 
create other AR like ORM in JAVA  but rather create AR like interface for 
existing ORM.  I expect discussion on additional methods that will conform the 
concept.

The solution requires Java 5 as generics and some other features are being 
used. Here are just a few code snippets of how it can be used.

Syntax examples:
EntityManager em=new EntityManager();
em.setContext(DataContext.createDataContext());

// create and save object
Contact contact=em.create(Contact.class);
em.saveChanges();

// find object by id
Contact contact=em.findById(Contact.class, id);

// find object by property
Contact contact=em.findFirstByProperty(Contact.class, "username",
form.getFieldValue("username"));

// find many objects by property
List contacts=em.findAllByProperty(Contact.class, "subdomain.name", 
"subdomain");

// find objects based on user defined query
List contacts=em.findAllByQuery(Contact.class,
                                Query.select().where("subdomain = $subdomain 
and age > $age")
                                              .param("subdomain", "agh")
                                              .param("age", 18)
                                              .order("lastname",true)
                                              .offset(200)
                                              .limit(10)
                                              
.include(Contact.ROLE_ARRAY_PROPERTY));

// count items per invoice
List counts=em.count(Item.class, "invoice_id")



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to