You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org> on 2008/08/03 22:29:11 UTC

[jira] Closed: (CAY-1070) Generating SelectQuery Access Code

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

Andrus Adamchik closed CAY-1070.
--------------------------------

    Resolution: Fixed

> Generating SelectQuery Access Code
> ----------------------------------
>
>                 Key: CAY-1070
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1070
>             Project: Cayenne
>          Issue Type: Task
>          Components: Cayenne Core Library
>    Affects Versions: 3.0
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.0
>
>         Attachments: DataMapGeneration.patch, NamingFixes.patch
>
>
> The original request for this feature was submitted as CAY-995. I am using a separate Jira to better formulate what needs to be done and provide the context. The goal to generate a flexible type-safe code to invoke mapped select queries. 
> 1. This feature should initially target class generation with Ant (via 'cgen' task [1]), although backend should be done in a way that should be later reusable with CayenneModeler and Maven plugins (actually all code generation stuff is done like that, so it won't be hard to follow).
> 2. The new feature will be activated in the "datamap" cgen "mode" (default mode is "entity"). Until now "datamap" mode always required a custom template to make any sense at all. Now it will result in generating a default predefined Java class (with a superclass if "makepairs" is true) per DataMap.
> 3. The new standard Velocity templates need to be created for "datamap" mode under "resources/dotemplates/v1_2", one for singleclass generation and two for subclass/superclass generation. Just like with persistent Java class templates, datamap-subclass.vm should be an empty class inheriting from a generated superclass; datamap-superclass.vm and datamap-singleclass.vm should be essentially the same thing except for the class name.
> 4. Generated class name should be derived from DataMap name and use DataMap.getDefaultPackage() for the package name. All non-Java identifier characters in the DataMap name should be replaced (with "_" ??) when deriving a class name. Superclass in a makepairs generation mode should be prefixed with "_" (same as persistent Java classes).
> 5. Generated classes must include the following:
> * A singleton method that returns a static final instance of the class:
>   protected static MyDataMap instance = new MyDataMap();
>   public static MyDataMap getInstance() {
>       return instance;
>   } 
> * A method for each mapped query. For each SelectQuery, a method would look like this:
>   public List<EntityClass> performQuery1(ObjectContext context, Object parameter1, Object parameter2, ...) {
>      // bind parameters and
>      // run the query here
>   }
>   
>   The number, names and order of parameters must match that of the mapped query (for SelectQuery that would require parsing qualifier expression to search for parameter nodes). also do something smart about parameter types (we can sort of guess them in SelectQuery), but this is not required for version 1 of the feature.
> [1] http://cayenne.apache.org/doc/cgen.html

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