DataObjects creation and registering with DataContext is an expensive operation. There are cases when only a few objects are really used, but the application still has to fetch a lot of objects. For instance when a user performs a search, result may contain thousands of records, but user will only check 2-3 of them. Cayenne allows programmers to explicitly disable objects creation for such cases. Results will be returned in the form of java.util.Map's. In Cayenne such maps are called DataRows.
Benefits of Data Rows:
- Fetch speed increase. Our tests show 2x to 5x performance increase.
- Using regular Cayenne query API.
- Using same DataMaps.
- Easy to convert to DataObjects.
Data rows don't have all the object-oriented features of DataObjects. In particular, data rows don't support relationships. It is easy to create a DataObject from a row though. See examples below.
Data rows example: