In our Cayenne ROP application we have some tables with very large BLOB fields. 
We want to be able to fetch the remaining columns to the client, without the 
BLOBs. I am after some ideas on how to best approach this:


1. Create two tables and two Cayenne Java entities to match

Cons: makes the code and database messy since we are dealing with one-to-one 
relationships where there isn't really any logical relation


2. Create one database table and use single-table inheritance: the superclass 
(say 'Painting') has all the fields and the subclass ('PaintingInfo') only the 
lightweight fields

Cons: the code is still messy since casting a PaintingInfo to Painting (should 
you want to view the BLOB) isn't really possible. You would have to get the PK 
and then perform another full fetch on the parent. And I'd be concerned about 
having two objects in memory at the same time which point to the same data, but 
aren't synchronised to each other.


3. Devise some mechanism for Cayenne to have not just hollow objects (like what 
happens with paged queries) but hollow attributes. Then we only lazily fetch 
the attribute data when it is needed (if at all). This could be ROP specific 
(that is, the BLOB attributes are fully fetched from the database but not sent 
to the client until needed) or perhaps this approach would also be useful in a 
non-ROP environment for lazily loading columns.



Any thoughts from people who have run into similar issues? I'd like to avoid 
DataRows and all that since that just makes the code really messy again.



Ari



--
-------------------------->
Aristedes Maniatis
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Reply via email to