Version 14.1 by John Huss on 2011/12/06 21:51

Hide last authors
madc0w 3.1 1 == **Comparison of EOF to Cayenne** ==
2
3 **Introduction**
4
5 EOF is the data access portion of WebObjects that provides Object-Relational Mapping (ORM).  Apache Cayenne is an alternative ORM that can be used within a WebObjects app as a replacement for EOF or in any sort of Java app, like a Servlet application.
6
7 Below is a description of the differences between EOF and Cayenne with the goal of providing information to a WebObjects/EOF developer who is curious about switching to Cayenne.
8
9 **Key Value Coding**
10
11 Cayenne doesn't really have a KVC mechanism like EOF does. Properties of entity objects can be accessed by name by using the readProperty and writeProperty methods of CayenneDataObject, but these methods do not invoke custom getters and setters like EOF does, they simple return the value. So they are analogous to storedValueForKey and takeStoredValueForKey (however, readProperty also supports a key path, not just a simple key).  
12
13 The closest match to KVC is found in a utility class: PropertyUtils.getProperty and PropertyUtils.setProperty.  These can be leveraged to provide access to property values that go through custom getters and setters. BUT the getter methods must be prefixed with "get", following the java-beans convention.
14
15 It should be noted however, that complete KVC can be added on top of Cayenne by using the JavaFoundation framework in WO, or by using the custom implementation found in the NSFoundation project that is in Project Wonder. This approach would provide a completely compatible KVC implementation on top of Cayenne.  An example of this is available in the ERCayenne framework in Project Wonder.
16
17 **Concurrency**
18
19 Cayenne has much better concurrency support that EOF. Locking the framework stack is not required as it is in EOF.  Cayenne also supports jdbc connection pooling out of the box.  I'm not aware of any benchmarks comparing performance, but Cayenne should be much faster at handling concurrent operations.
20
21 **Raw Rows**
22
23 In Cayenne raw row fetches are limited to returning columns from a single table. This differs from EOF which allows for any related key path to be fetched.  In Cayenne the qualifier may still reference key paths, they just cannot be returned in the select.
24
25 **Inheritance**
26
27 Cayenne currently supports only single table inheritance and vertical inheritance. However, horizontal inheritance is slated for implementation in the next release of Cayenne (3.1).
28
29 **Tooling**
30
31 CayenneModeler is a standalone application that can be used on any platform.  There is also an Eclipse plugin under development that should be viable soon.  The Eclipse plugin will allow for automatically regenerating entity classes when the model is modified, but the standalone app doesn't this (not directly anyway).
32
33 **Entity Templates**
34
35 The default entity templates in Cayenne are pretty sparse, without a lot of convenience methods like the WonderEntity template has for EOF. But this is easily remedied, and the ERCayenneExample in Wonder has and EOF-like template you can use.
36
37 **Modeler / Model API**
38
John Huss 14.1 39 In Cayenne each Entity has two parts: 1) an Object mapping and a DB mapping, referred to as ObjEntity and DbEntity.  These appear separately in Modeler and are linked together within Modeler.  ObjEntity contains the attribute name and java class type; DbEntity contains the column name and database type.  This differs from EOF where these two concepts are combined into a single editor in the Modeler and into a single EOEntity class at runtime. Whilst I find the separation in Cayenne to be a bit cumbersome, it allows for for possibility for operations to be performed at a lower level using just the database information and bypassing the object layer. This may be useful in a small number of specific situations.
madc0w 3.1 40
41 **Deployment**
42
43 Cayenne is agnostic to the specific deployment environment, however it is almost always deployed to a standard Java Application Server (Servlet container) like JBoss or Glassfish, etc. This is an industry standard approach, which has some advantages. Personally, I quite like that the app is entirely contained in a single .war file.
44
45 However, Cayenne can easily be used in a WO application as it is just another jar and doesn't have any special deployment requirements.
46
47 **Feature Matrix**
48
49 |= Feature |= EOF |= Cayenne |= Notes
50 | Open Source | | X
51 | Still Developed / Maintained | | X | WebObjects/EOF has been given legacy status by Apple.
52 | Development on any Platform | | X | WebObjects/EOF may only be developed on Apple hardware.
53 | Eclipse Integration | X | | Cayenne Eclipse integration is being developed and an alpha version is available.
54 | Good Concurrency Support | | X | EOF is single threaded and requires explicit locking, preventing concurrent operations.
55 | Support for all common DBs | X | X |
56 | Primitive Attributes
57 \\(int, double, long, etc) | | X |
John Huss 14.1 58 | Enum Attributes | X | X | Enum attributes are supported in EOF via the javaEnum prototype in Wonder.
madc0w 3.1 59 | Relationships with Map or Set collection types | | X |
60 | Custom Attribute Types | | X | The ERAttributeExtension framework in Wonder can provide this support for EOF.
61 | Embeddable relationships
John Huss 14.1 62 \\(related objects stored in same table as the source) | | X | EOF allows mapping relationships to the same table as the parent and using the same entity class.  Cayenne allows embedding objects of a different class as de-normalized relationships in a single column.
madc0w 3.1 63 | Single Table Inheritance | X | X |
64 | Horizontal Inheritance | X | | Horizontal inheritance is being developed and targeted for the next release of Cayenne (3.1)
John Huss 14.1 65 | Vertical Inheritance | X | | Cayenne's vertical inheritance support is not yet complete
madc0w 3.1 66 | Flattened attributes/relationships | X | X |
67 | Automatic Bi-directional Relationship Management | X | X | EOF support is optionally provided by Wonder.
68 | Generics support (Java 5) | | | Generics support is mostly artificial in both EOF and Cayenne (implemented by casting in entity template).
69 | Support Transient Objects
John Huss 14.1 70 \\(objects not in editing context) | X | | {{color value="#000000"}}Cayenne supports Transient object manipulation for attributes, but not relationships.{{/color}}
madc0w 3.1 71 | Support for Generic Objects (no custom classes) | X | X |
72 | Optimistic Locking | X | X |
73 | Optional Editing Context Synchronization | | X | EOF automatically synchronizes editing contexts which can hide Optimistic Locking problems.
74 | Key Value Coding | X | | Cayenne has some utility methods to access bean properties, and support for raw data access like storedValueForKey provides for EOF, but no direct analog to KVC.
75 | Customizable entity templates | X | X |
John Huss 14.1 76 | Raw fetching (Raw Rows / Data Rows) | X | X | Cayenne's raw fetching is limited to fetching attributes, not relationships (see [[here>>http://cayenne.apache.org/doc/data-rows.html]]), but other lower level support is available without resorting to raw SQL.
madc0w 3.1 77 | Direct SQL support | X | X |
78 | Nested Editing Contexts | X | X |
79 | Editing Context Undo | X | |
80 | Remote / Distributed Data Access (Client apps) using API directly | X | X |
John Huss 14.1 81 | Android Support | | | Android support is available with a [[patch>>https://issues.apache.org/jira/browse/CAY-1604]] to Cayenne. EOF will run on Android, but the license does not allow it.
madc0w 3.1 82 | Pluggable Cache Implementation | | X |
John Huss 14.1 83 | Database Migrations | X | | Migrations are available in Cayenne with a pending [[patch>>https://issues.apache.org/jira/browse/CAY-1633]] (vote it up).  CayenneModeler has the ability to inspect schema and migrate it as an one-time Admin function.
84 | [[EJBQL>>http://cayenne.apache.org/doc/ejbqlquery.html]] Query support (defined by JPA spec) | | X |
85 | Raw SQL Templating | | X | Cayenne allows SQL to be written using the velocity [[template>>http://cayenne.apache.org/doc/sqltemplate-query.html]] language and stored in the model so it can support multiple database types.
86 | Batch Querying | | X | Cayenne provides this using [[QueryChain>>http://cayenne.apache.org/doc/querychain.html]]
madc0w 3.1 87 | Servlet Deployment | X | X |
88 | JavaMonitor / wotaskd Deployment | X | X |
89 | Incredible Community and Conferences | X | |
90
91 **API Comparison**
92
93 For EOF users wanting to use Cayenne there is very little to learn to get started. The frameworks are conceptually very similar at the user level, so you just have to translate your EOF knowledge to some new method and class names.
94
95 |= EOF |= Cayenne
John Huss 9.1 96 | **EOEditingContext**
97 | **DataContext**
madc0w 3.1 98
John Huss 9.1 99 | .objectWithFetchSpecification
100 | .performQuery
madc0w 3.1 101
John Huss 9.1 102 | .saveChanges
103 | .commitChanges
madc0w 3.1 104
John Huss 9.1 105 | .revert
106 | .rollbackChanges
madc0w 3.1 107
John Huss 9.1 108 | .lock
109 | Locking is not necessary in Cayenne
madc0w 3.1 110
John Huss 9.1 111 | .unlock
112 | Locking is not necessary in Cayenne
madc0w 3.1 113
John Huss 9.1 114 | .insertObject
115 | .registerNewObject
madc0w 3.1 116
John Huss 9.1 117 | .deleteObject
118 | .deleteObject
madc0w 3.1 119
John Huss 9.1 120 | .undo
121 | No analog in Cayenne
madc0w 3.1 122
123 | |
John Huss 9.1 124 | **EOGenericRecord**
125 | **CayenneDataObject**
madc0w 3.1 126
John Huss 9.1 127 | .storedValueForKey
128 | .readProperty
madc0w 3.1 129
John Huss 9.1 130 | .takeStoredValueForKey
131 | .writeProperty
madc0w 3.1 132
John Huss 9.1 133 | .valueForKey
134 | PropertyUtils.getProperty (sort of, see KVC section above)
madc0w 3.1 135
John Huss 9.1 136 | .takeValueForKey
137 | PropertyUtils.setProperty (sort of, see KVC section above)
madc0w 3.1 138
John Huss 9.1 139 | .globalID
140 | .getObjectId
madc0w 3.1 141
John Huss 9.1 142 | .entity()
143 | Cayenne.getObjEntity(eo)
madc0w 3.1 144
John Huss 9.1 145 | .validateForSave
146 | .validateForSave
madc0w 3.1 147
John Huss 9.1 148 | .validateForInsert
149 | .validateForInsert
madc0w 3.1 150
John Huss 9.1 151 | .validateForUpdate
152 | .validateForUpdate
madc0w 3.1 153
John Huss 9.1 154 | .validateForDelete
155 | .validateForDelete
madc0w 3.1 156
John Huss 9.1 157 | .validateValueForKey
158 | No analog in Cayenne
madc0w 3.1 159
John Huss 9.1 160 | .<validateSpecificAttributeViaReflection>
161 | No analog in Cayenne
madc0w 3.1 162
John Huss 9.1 163 | .willUpdate, willInsert, etc
164 | provided by Cayenne lifecycle callbacks
madc0w 3.1 165
166 | |
John Huss 9.1 167 | **EOQualifier**
168 | **Expression**
madc0w 3.1 169
John Huss 9.1 170 | EOQualifier.qualifierWithQualifierFormat
171 | Expression.fromString
madc0w 3.1 172
173 | |
John Huss 9.1 174 | **ERXKey**
175 | **ExpressionFactory** (sort of, see the Key class in ERCayenneExample framework in Wonder&nbsp;for a direct analog)
madc0w 3.1 176
John Huss 9.1 177 | ERXKey.eq
178 | ExpressionFactory.matchExp (sort of)
madc0w 3.1 179
John Huss 9.1 180 | ERXKey.ne
181 | ExpressionFactory.noMatchExp (sort of)
madc0w 3.1 182
183 | |
John Huss 9.1 184 | **EOFetchSpecification**
185 | **SelectQuery**
madc0w 3.1 186
John Huss 9.1 187 | .qualifier
188 | .getQualifier
madc0w 3.1 189
John Huss 9.1 190 | .setSortOrderings
191 | .addOrderings
madc0w 3.1 192
John Huss 9.1 193 | .setPrefetchingRelationshipKeyPaths
194 | .addPrefetch
madc0w 3.1 195
196 | |
John Huss 9.1 197 | **EOEntity**
198 | **ObjEntity + DbEntity**
madc0w 3.1 199
John Huss 9.1 200 | **EOModel**
201 | **DataMap (entities) + DataNode (connection dictionary)**
madc0w 3.1 202
John Huss 9.1 203 | **EOAttribute**
204 | **ObjAttribute**
madc0w 3.1 205
John Huss 9.1 206 | **EOClassDescription**
madc0w 3.1 207 | **DataObjectDescriptor**