cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: 4.1 templates with relationships
Date Tue, 17 Jul 2018 17:12:50 GMT
> I'm experimenting with 4.1 and field-based DataObjects. I noticed, using the standard
4.1 server superclass template, that the fields that cover relationships aren't narrowly typed
but are simply specified as Object, which is apparently necessary because they may get populated
with a ToOneFault or a ToManyFault. Is there really no way to get these types more specific?

I guess an alternative way is to create pairs of typed fields ("T related", "ToOneFault relatedFault").
This will have memory overhead though. IIRC 8 bytes per object per relationship on a 64-bit
architecture, i.e. not that small, considering how may objects one might keep in memory. So
our performance improvement benchmarks vs 4.0 won't look as impressive :) 

> I also noticed that the template specifies the field scope as protected. Isn't that unnecessarily
broad? 

I suspect since getters are doing extra work, it was decided to expose bare ivars to allow
subclasses to manipulate them directly. Having said that, there's always "readPropertyDirectly(..)"
and "writePropertyDirectly(..)" to access those fields in any special yet-unforeseen cases.
So I wouldn't mind if we make the ivars private in the future releases.

BTW, with your Gson serialization, how do you deal with controlled serialization of essentially
infinite graphs? Do you provide a spec of how deep to go down the relationships path?

Andrus


> On Jul 17, 2018, at 4:48 PM, Maik Musall <maik@selbstdenker.ag> wrote:
> 
> Hi,
> 
> I'm experimenting with 4.1 and field-based DataObjects. I noticed, using the standard
4.1 server superclass template, that the fields that cover relationships aren't narrowly typed
but are simply specified as Object, which is apparently necessary because they may get populated
with a ToOneFault or a ToManyFault.
> 
> Is there really no way to get these types more specific? One of my experimentation goals
was to use Gson to serialize DOs from and to JSON, and the field-based approach would make
that very simple, were it not for the relationships.
> 
> I also noticed that the template specifies the field scope as protected. Isn't that unnecessarily
broad? My application works fine with those fields being private (which also makes the Gson
case easier because I can just tell it to cover all private fields, automatically ignoring
snapshotVersion, objectId, persistentState and other internal fields).
> 
> Maik
> 


Mime
View raw message