Niclas Hedhman wrote:
Secondly, the 'many types' --> I have not checked out the details of
this yet. Rickard is the man!!

Ok, so on "many types", the support is in there on the EntityStore and UoW level, but there is as yet no support for it in the API. So, the main remaining question is: how do you add/remove types from an Entity?

I'm guessing that it would have to be an explicit operation, rather than just "oh so you want to cast an Entity to X, sure I'll add it on the fly" kind of thing. So, one way to do that would be to extend the EntityBuilder in UoW to work similarly to how ValueBuilder can take an existing value and modify it:
ArticleEntity article = ...;
EntityBuilder<CommentsEntity> commentsBuilder = uow.addEntityType(CommentsEntity.class, article);
CommentsEntity ce = commentsBuilder.prototype();
... initialize CommentsEntity state ...
CommentsEntity ce = commentsBuilder.newInstance();

This would add the entitytype CommentsEntity to the already existing article instead of creating a new one. Code can then access it through either type:
WrittenPiece wp = uow.get(WrittenPiece.class, "somearticleid");
Commentable c = uow.get(Commentable.class, "somearticleid");

wp and c would refer to the same Entity, but use different EntityTypes for access.

/Rickard

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

Reply via email to