cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: Is it possible/easy to integrate cayenne with other frameworks?
Date Tue, 06 Dec 2011 15:04:42 GMT
For the DB connection, if you're using 3.0 there is some info here:
https://cwiki.apache.org/CAY/setting-database-connection.html

For 3.1, you can use a properties file to store the value and load them in
a custom DI module by doing something like:

public class PropertiesModule implements Module {
public void configure(Binder binder) {
MapBuilder<Object> mapBuilder =
binder.bindMap(DefaultRuntimeProperties.PROPERTIES_MAP);
Properties props = ... load properties from a file
for (Object keyObj : props.keySet()) {
String key = (String)keyObj;
                        mapBuilder.put(key, props.get(key));
                }
}
}

Where the properties are set like this:
cayenne.jdbc.driver.MyDomain.MyNode=org.postgresql.Driver
cayenne.jdbc.url.MyDomain.MyNode=jdbc:postgresql://localhost/mydb
cayenne.jdbc.username.MyDomain.MyNode=postgres
cayenne.jdbc.password.MyDomain.MyNode=*******
cayenne.min.connections.MyDomain.MyNode=1
cayenne.max.connections.MyDomain.MyNode=1

You can use Cayenne without running the modeler, but it would be rather
cumbersome since you would have to create the whole model programmatically
at runtime each time.  And normally you would generate custom classes for
your Entities (objects), but without having a pre-existing model you would
just have to use CayenneDataObject directly which will force you to access
values by name instead of via getters and setters.
If those requirements are acceptable, then it could work.

The "update" method might be tricker.  Cayenne saves all changes to the
entire object graph at once; you can't just save one object, you save all
changes to the related objects that are loaded and modified.  If this is
different than the "update" concept in Isis then it may be a problem.

John

On Tue, Dec 6, 2011 at 12:59 AM, Kevin Meyer - KMZ <kevin@kmz.co.za> 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 "isis.properties" 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
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message