You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2011/02/23 15:04:38 UTC

[jira] Updated: (CAY-877) ROR ActiveRecord like interface for Apache Cayenne

     [ https://issues.apache.org/jira/browse/CAY-877?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik updated CAY-877:
--------------------------------

    Fix Version/s:     (was: 3.1M1)
                   3.1 (final)

> ROR ActiveRecord like interface for Apache Cayenne 
> ---------------------------------------------------
>
>                 Key: CAY-877
>                 URL: https://issues.apache.org/jira/browse/CAY-877
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Core Library
>    Affects Versions: 2.0 branch
>            Reporter: David Marko
>            Assignee: Andrus Adamchik
>            Priority: Minor
>             Fix For: 3.1 (final)
>
>         Attachments: EntityManager.java, Query.java
>
>
> 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.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira