Apache Cayenne 3.0 Supports Remote Object Persistence and ORM Modeling Tools
The new version of Apache Cayenne, an open source Java framework for object relational mapping and persistence, supports Remote Object Persistence and ORM Modeling Tools. Version 3.0 of the framework was released back in May. With Cayenne's Remote Object Persistence feature, Java objects can be persisted out to clients via Web Services. The framework also supports database reverse engineering and generation, as well as a Velocity-based class generation engine.
InfoQ caught up with Andrus Adamchik (VP) and Aristedes Maniatis (Project Management Committee member) from Cayenne team to speak about features in the new version and future road map of the framework.
InfoQ: Why another ORM framework when Apache already has OpenJPA project?
Cayenne is actually the older project. Its first release was in July 2002 and moved to Apache in 2006. At any rate, Apache often has overlapping projects with similar goals and this adds to the choice for end-users. Each ORM has a different focus and offers different solutions to similar problems. We are all enriched by the choice available.
InfoQ: Does Cayenne support JPA 2.0 specification?
No. There was a lot of work spent on implementing the first version of JPA specification, however it was decided in 2008 to abandon that approach. Not only was it a lot of work, but it restricted the ability of Cayenne to implement more innovative approaches. We had strong support from the user base and we believe that developers choose Cayenne for the clean API and the additional features it offers. These things aren't always compatible with following a rigid standard. Cayenne does support almost all of the JPA concepts through, including the ability to execute EJBQL.
InfoQ: Does Cayenne framework provide any features outside the JPA spec?
Yes. Cayenne offers a number of innovative features such as (1) ROP (Remote Object Persistence) which allows remote Java applications to access Cayenne web service instead of directly accessing the database. This allows for separation of business logic between multiple application tiers, with each tier using the same persistence APIs; (2) generic objects mapping, allowing to instantiate mapping dynamically in runtime instead of compile time; (3) nested ObjectContexts. Cayenne also has a 'modeler' application developed by the same team which makes it easier to visualise the database and Java hierarchy, and which is always in sync with the most current framework version.
InfoQ: What type of monitoring support is provided by Cayenne framework for the developers and Operators to view persistence and caching details?
Cayenne supports a callback/listener mechanism similar to JPA. It also has extensive logging built in. JMX extensions to monitor the underlying stack have been already prototyped and will likely be included in upcoming 3.1. Also since Cayenne query cache is pluggable, users can rely on event mechanism of their cache provider to implement JMX monitoring of cache independently from Cayenne. This has been actually done on some projects we are aware of.
InfoQ: Can you discuss the new Dependency Injection (DI) container feature that will be part of the future release of the framework?
Cayenne DI container is small (about 35K in size), XML-free, easy to use and has no external dependencies (not even on Cayenne). It's goal is to load and manage the Cayenne runtime, but otherwise to stay as unassuming as possible. This means it won't interfere with applications' use of Spring, Guice, etc. It will just deal with Cayenne, and provide extension points for users to customize Cayenne behavior.
Implementation-wise it is influenced by Google Guice. Dependencies are configured via constructor or field annotations. Most common DI features are supported - binding of classes, instances or instance providers, binding of named maps and lists, merging multiple modules into one container on startup, binding scopes, fluent binding API, lazy instantiation. Unlike Guice, our DI has a concept of scope lifecycle which is very important for a framework like Cayenne. DI-managed objects can annotate their methods to receive scope events, most often to release some resources at the end of the scope. Users can easily create their own scopes and set up custom events (e.g. a web request scope). Considering the small size of the DI jar, that is quite a lot of features. The only important DI piece missing is dynamic proxies and interception. We may still add that in the future.
InfoQ: What is the future road map of Apache Cayenne project in terms of new features and enhancements?
Recent discussions and work have included: a new query API fully supporting generics, and reconciling JPA-style EJBQLQuery with Cayenne traditional SelectQuery; support for merging of multiple mapping projects into one in runtime to improve modularity; ongoing work to deal with the idiosyncrasies of different databases; taking advantage of the DI capabilities to refactor the core services for ease of extension (this also covers the above-mentioned JMX extensions); enhancements to the Cayenne Modeler to make it more powerful and easier to use.
But as with all open source projects, exactly what is developed will be driven by user demand and where the most productive advances can be made with the given developer resources.
Stephanie Davis (nee Stewart) Dec 21, 2014