FAQ
Cayenne has very nice functionality for paging large lists of objects, so that the list is mostly hollow objects which are retrieved in a lazy fashion as they are accessed.

This works well to fetch 100,000 contacts in a list and only draw the ones visible to the user as they scroll. What works less well is the common use case of a list view where you might only want to show several attributes of a large record.

So a list of contacts might show just:

* firstName
* lastName
* totalSales

To fetch this data requires a query on contact with a prefetch to invoices. Lots of data being loaded from two or more tables and potentially a bit slow.

Some options:

1. Use DataRows. This is simple, but you lose some of the nice modelling/entity features from Cayenne. You have to type all the columns yourself.

2. Create a view in the database with just three columns (plus a PK) and create a separate read-only Cayenne model which maps to that view. But now you are hardcoding your application to a specific database and changing the representation is hard.

I want something half way between the two. SQLtemplate to fetch only the columns or aggregates I need, but mapped to some sort of read-only lightweight Cayenne entity.


Has anyone tried something like this?


Ari



--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
groupuser @
categoriescayenne
postedApr 15, '15 at 9:22a
activeApr 16, '15 at 5:35p
posts5
users4
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase