Hi everybody,

Wanted to give heads up on a feature that I we are working on with my (yet 
under the radar) colleague [1]. This will be in Jira soon and implementation 
should be on the way. 

We’ve experimented with automated db-first approach to Cayenne modeling for 
more than a year on a set of client projects. Roughly this approach means that 
DB evolution is managed via external tools (e.g. liquibase) and Cayenne 
artifacts are managed using the following POM configuration:

<plugin>
        <groupId>org.apache.cayenne.plugins</groupId>
        <artifactId>maven-cayenne-plugin</artifactId>
        <configuration>
                ...
        </configuration>
        <executions>
                <execution>
                        <id>default-cli</id>
                        <goals>
                                <goal>cdbimport</goal>
                                <goal>cgen</goal>
                        </goals>
                </execution>
        </executions>
</plugin>

“cdbimport” ensures that Cayenne model is always in sync with DB, “cgen” - that 
Java classes are in sync with the model. There are zero problems with “cgen", 
not so with “cdbimport". If you control the schema, you get a decently named 
Java classes/properties in 95% of the cases. Here we are trying to address the 
remaining 5% that make things ugly:

* Inability to generate meaningful relationship names in many cases.
* Inability to customize attribute/relationship names and data types.

To solve this here we are proposing a merge algorithm that would preserve 
customizations to the Obj* layer made by the user. And in addition to that a 
special descriptor that can be used for more advanced filtering and 
customization of cdbimport process. Both of these improvements will hopefully 
result in “cdbimport” becoming a tool of choice for Cayenne work for many users.

Comments are welcomed.

Cheers,
Andrus


[1] 
https://docs.google.com/document/d/1DF5-_mMDCuH7iUFhEFDm2q-ebVeSPgvOaymho88ywJ0/edit?pli=1

Reply via email to