cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Is it possible/easy to integrate cayenne with other frameworks?
Date Fri, 09 Dec 2011 02:18:57 GMT
Hi Kevin,

I should say that Cayenne is uniquely suited for creating persistent stack and mapping at
runtime, as there's no class enhancement involved. POJO's being subclasses of CayenneDataObject,
with set/get implemented the way we do them in Cayenne is the only hard requirement. From
there, as John has mentioned, you make some assumptions. The biggest assumption is that you
control the DB and there's no chance of a legacy schema that you'd have to support (in which
case you will need to create Cayenne mapping by hand to reconcile column naming and type differences
between Java and DB). 

Implementation (assuming Cayenne 3.1) may be encapsulated in a custom Cayenne DI module. We
are still in the process of writing the docs for 3.1, but most DI features are well documented
in this otherwise empty PDF:

In the custom module define DataDomain loading services to reverse-engineer the POJOs instead
of loading mapping from XML. This is the biggest task, requiring some understanding of Cayenne
APIs. Feel free to ask here if you get stuck with anything. Also map SchemaUpdateStrategy
to CreateIfNoSchemaStrategy that will create a DB schema based on your mapping.

This should be it at the high level, but of course you'll need to write some code here. I
used to implement a similar task - going from reverse-engineered DB to a runtime mapping of
generic Java classes, and that worked pretty well.

Good luck, and let us know how this works - maybe some of these new factories that you develop
could be of general use to Cayenne users as well as ISIS users.


On Dec 5, 2011, at 8:59 PM, Kevin Meyer - KMZ wrote:

> Hi all,
> Please point me to the previous message if this has already been 
> addressed.. I did a quick search, but couldn't find anything that looked 
> directly relevant.
> Anyway: I have been maintaining the SQL Objectstore (jdbc) for 
> Apache Isis (currently in the incubator), and would like to know if 
> Cayenne can be used completely "in the background", with no user 
> integration (i.e. no need to run the configuration tool / modeller / etc).
> Isis is a complete framework solution for developing and deploying 
> POJO / domain objects, and provides hooks for persistence tasks.
> For example, the metamodel context provide:
> 	public ObjectInstantiator getObjectInstantiator();
> 	public ObjectDirtier getObjectDirtier();
> 	public ObjectPersistor getObjectPersistor();
> where, for example:
> public interface ObjectInstantiator extends Injectable {
>   /**
>     * Provided by the <tt>ObjectFactory</tt> when used by framework.
>     * 
>     * <p>
>     * Called by {@link ObjectSpecificationDefault}.
>     */
>    Object instantiate(Class<?> cls) throws 
> ObjectInstantiationException;
> }
> Isis requires no annotations, etc, to support persistence, which is 
> taken care of via introspection. Some hints can be provided to the 
> objectstore via the "" file, if required.
> So, I would like to know how difficult would it be to "just" hook Cayenne 
> into the object "create", "find" and "update" methods of Isis, and let  
> Cayenne take care of the ORM / persistence?
> Taking a quick browse through the examples, I don't see where I 
> configure the database connection, for example.
> Regards,
> Kevin

View raw message