[TYPO3-team-core-v5] RFC: Open question on support for associative array properties in persistence
Karsten Dambekalns
karsten at typo3.org
Thu Nov 13 21:44:58 CET 2008
Hi.
Bastian Waidelich wrote:
> For me it's still a bit unclear how to handle sub-references in TYPO3CR
> in general. I can't really think of a scenario where array-properties in
> domain objects would make sense..
Well, in most cases to hold references to other objects, but still
highly probably some domain objects contains arrays of something else.
> Let's take the Blog for instance:
> Right now _posts_ is an array-property of _Blog_ which forces us to load
> all posts into RAM to find a single post by its UUID.
Well, lazy loading should be applied only if needed, not the other way
around. :)
> And we have to instantiate a _Blog_ instance to retrieve its _posts_,
> there is no "find all posts of blog xy" AFAIK.
Well, that's how aggregates work in that regard. And it's DDD, otherwise
you are already very close to "SELECT FROM posts WHERE blog_id=34"...
When you have the Blog instance, your posts are already there
.
> And then - back to the topic - wouldn't _posts_ rather be some kind of
> Collection of F3::Blog::Domain::Post, and the "array key" the identifier?
Of course that makes sense, although not strictly needed (if you make
sure you only accept objects of the right type in, say, add() you don't
need a typesafe collection).
But still, deep inside even the collection holds an array. And you still
have some key-value relationship. So we still need to put that stuff
into the CR.
> Anyway, when using arrays I'd definitely agree to Robert: If I would
> forget (or didn't know about) some @preservekeys annotation this would
> lead to unexpected results. And worse, it would lead to unexpected
> results only in some cases.
> My opinion in general: As little magic (in the sense of new concepts,
> new annotations, unusual behavior) as possible.
Ok, thanks.
Regards,
Karsten
More information about the TYPO3-team-core-v5
mailing list