cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@xsinet.co.za
Subject Re: partially hollow objects
Date Tue, 19 Feb 2013 06:51:50 GMT
A method that I have used as a 4th option:

4.  Have one database table, however the Cayenne class doesn't include the
BLOB field as an object attribute but as a relationship attribute. So
you'll need a 2nd Cayenne class to hold the BLOB field.

So the Cayenne DbEntity has a 1:1 relationship with itself which will be
used to retrieve the relationship BLOB attribute when required.


I would prefer option 3 on your list Ari:
It would be nice if there was a checkbox next to BLOB object attributes
that could be marked for lazy retrieval. Cayenne could easily retrieve a
marked field with a 2nd call to the db using the rows PK.

Jurgen


> 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
>





Mime
View raw message