On Wed, May 16, 2012 at 12:44 PM, Niclas Hedhman <[email protected]> wrote:
> On Wed, May 16, 2012 at 7:22 AM, Tibor Mlynarik
> <[email protected]> wrote:
>
>> Can somebody please explain to me why are *DTOs ( value composites
>> that mirrros entities) necessary
>> and why only values can be serialized into JSON and entities not ?
>
> Uhhhh.... The history is probably forgotten. If we instead look
> forward, in 2.0 I expect that entities can be turned into Values with
> a simple toValue() method, since Rickard fixed that Values can now
> contain (Many)Associations. And since inheritence from Composite meta
> types are not going to be necessary in 2.0, I expect something like
> this to work;
>
> Person pEntity = uow.get( Person.class, "niclas" );
> Person pValue = pEntity.toValue();
>
> OR, since toJSON() is probably going into Module.toJSON( Object value
> ), or something like that (since Values no longer need to inherit
> ValueComposite), perhaps it will look like;
>
> Person pEntity = uow.get( Person.class, "niclas" );
> Person pValue = module.toValue( pEntity);

hmm, and isn't the only reason to convert entity into value to be able
to serialize it (to JSON) ?
For what else is good such transform ?
I can see reason could be that after uow has completed entities are
unusable. But what is rationale behind this behaviour ? When I want to
develop 3-tier system now, I have to use only values on client/UI
tier.

I think that value serialization should have different schematics than entities.
To serialize entity one should be able to specify graph depth,
similarly as fetch plan. Cycles should be supported and repeated
entities should be serialized by internal refs.

cheers,

 - Tibor

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to