Le 17 août 2009 à 10:52, Rickard Öberg a écrit :
philippe van dyck wrote:
But the most important problem is the presence of EntityType in
MapEntityStore :
public interface MapEntityStore
{...
Reader get( EntityReference entityReference, EntityType
entityType)
throws EntityStoreException;
...}
The S3 ES will not compile until this is changed, sorry!
This is absolutely impossible to do though, since the UoW code has
no way of knowing what type to send in, in the general case.
Example: in my own app I have a Describable mixin type that about 10
EntityTypes extend. Therefore there will be 10 potential
EntityModels that could be used if I do uow.get(Describable.class,
"1234"), and the UoW has no idea of knowing which one to pick. It
could try them one at a time, but that would be stupid as on average
that will give 5 misses.
But, correct me if I am wrong, that is what you are doing right now...
In UnitOfWorkInstance, you iterate the potential models and call
"getEntity" each time :
for (int i = 0; i < potentialModules.size();
i++) {
ModuleInstance potentialModule =
potentialModules.get(i);
EntityStore store =
potentialModule.entities()
.entityStore();
EntityStoreUnitOfWork storeUow =
getEntityStoreUnitOfWork(
store, potentialModule);
try {
entityState =
storeUow.getEntityState(identity);
} catch (EntityNotFoundException e) {
continue;
}
....
I am missing something, obviously...
The best solution I can think of is to embed the type information in
the id itself, so that the EntityStore can use that to switch
buckets internally. To do that you need to ensure that id's are
generated with type information in it. The easiest way to do that is
to have your EntityStore implement IdentityGenerator, because when
an identity is generated you will get the Entity type as a parameter.
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev