Apache Cayenne 3.0 and the State of the Project

DZone 's Guide to

Apache Cayenne 3.0 and the State of the Project

· Java Zone ·
Free Resource
After 9 years as an active Top Level Project at Apache, the Cayenne project released version 3 of its ORM and remoting services persistence framework.  Cayenne VP Andrus Adamchik believes that Cayenne 3.0 has what it takes to compete with the best Java ORMs like Hibernate.  The foundations of Cayenne's design provide 'rich' persistent objects and a clean separation between the mapping model and Java code.  Adamchik says those choices have endured for nearly a decade: "they survived POJO/annotation hype rather well,enabling smooth database access experience and a number of rather unique features not found (maybe even not possible) in other ORMs."  Cayenne 3.0 continues to extend the abilities of its ORM with those founding principles in mind.

Cayenne supports database reverse engineering and generation, as well as a Velocity-based class generation engine.  These utilities are controlled through the CayenneModeler GUI tool, requiring no XML or annotation based configuration.  Cayenne also provides database generation, Web Services and non-Java client integration, schema mapping, on-demand object and relationship faulting, database auto-detection, and more.

A very long list of additional features were added to Cayenne 3.0.  The upgrade drops right into an older existing Cayenne project, and the only problems with backward compatibility would be that the saved files in CayenneModeler 3.0 don't work with previous versions.  Cayenne committers thought about building a JPA provider on top of the runtime, but ultimately decided to stay away from JPA.  Many of the new features came out of this idea however.  

Java 5 is now the minimum requirement for Cayenne 3.0 and generics are now supported.  Object properties can be mapped to columns from a joined table over one or more joins.  You can also declare a callback method on an entity object or declare a listener class, or register it via API, to receive entity events, JPA-style.

Other features include:

  • A Pluggable Query Cache
  • EJBQL Object Queries as Strings
  • SelectQuery improvements
  • More Tools for CayenneModeler
  • Performance Improvments

Adamchik explained what developers who used Cayenne for the first time thought about it:

"Programmers who haven't used Cayenne before will find it a powerful and easy to use ORM, distinguished from other ORM tools by a clean and intuitive API, powerful three tier (ROP) option, flexible caching, a GUI modeler tool and much more. Cayenne is extremely stable; its huge suite of tests and long history mean that it is fast and reliable."

The project website cites three points that set Cayenne apart form other ORMs

  1. Cayenne can work in three-tier (ROP) mode connecting multiple clients through remote Cayenne controlled services, not JDBC.  This brings more control to caching and centralized validation through a variety of clients.
  2. Cayenne can use generic classes and define the mapping dynamically at runtime without needing to know the class at compile time and without bytecode manipulation.
  3. Nested contexts provide an arbitrary number of nesting levels for commit/rollback operations so users can create "scratch contexts" for working with objects and preserving a larger set of uncommitted changes.

Future Releases
Planning and development for Cayenne 3.1 is well underway.  A dependency injection container is already available in the project's Subversion trunk.  The committers don't want to introduce a complex new runtime like Spring or Guice yet.  The DI container won't create version conflicts with these runtimes.  3.1 will also finalize the support of generics in queries.

ObjectStyle offers commercial support for Apache Cayenne.  You can download Cayenne here.  The newly released Technical Fact sheet can be found here

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}