clouway / twig-persist

twig-persist
0 stars 3 forks source link

Twig cannot load child entities #5

Open IvanLazov opened 10 years ago

IvanLazov commented 10 years ago

In order to produce this bug, weve change the way for updating the Contract

Here are the changes that weve made to the UpdatesContractImpl.class


contractBase.updateContract(contract);

/**
 * Add the following
**/
contractBase.getContractByCode(contract.getContractCode());

eventBus.get().fireEvent(new ContractUpdatedEvent(contract.getContractCode()));

Then, we try to update the contract and receive the following error

java.lang.IllegalStateException: Some instances were not found for keys [Contract("4231338")/Address(199)] found {}
    at com.google.code.twig.standard.TranslatorObjectDatastore.doRefreshActivate(TranslatorObjectDatastore.java:748)
    at com.google.code.twig.standard.TranslatorObjectDatastore.refresh(TranslatorObjectDatastore.java:718)
    at com.clouway.telcong.crm..contract.server.PersistenceContractBase.getContractByCode(PersistenceContractBase.java:141)
    at com.clouway.telcong.crm..contract.server.ContractFinderImpl.findContractByCode(ContractFinderImpl.java:141)
    at com.clouway.telcong.crm.contract.server.ContractLocator.find(ContractLocator.java:33)
    at com.clouway.telcong.crm.contract.server.ContractLocator.find(ContractLocator.java:10)
    at com.google.web.bindery.requestfactory.shared.Locator.isLive(Locator.java:96)
    at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.doIsLive(LocatorServiceLayer.java:188)
    at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.isLive(LocatorServiceLayer.java:85)
    at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
    at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
    at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.createReturnOperations(SimpleRequestProcessor.java:282)
    at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:240)
    at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
    at com.evo.adm.communication.server.injectingrequestfactory.InjectingRequestFactoryServlet.doPost(InjectingRequestFactoryServlet.java:60)

The problem occurs when we execute getContractByCode. In this method we refresh the Contract/ProvidedService and then when we try to refresh the Contract/ServiceAddress, Twig again tries to refresh it's cache by loading the entities from the Datastore, but fails in the BaseObjectDatastore class method serviceGet(Collection keys, Settings settings)

protected final Map<Key, Entity> serviceGet(Collection<Key> keys, Settings settings)
{
   ...

   // get entities from the datastore
   statistics.datastoreGets++;
   Map<Key, Entity> fromDatastore = service(settings).get(keys);
}

The datastore doesn't retrieve any results. Also the main cache of twig KeyInstanceCache (containing cache for keyToInstance and instanceToKey) is containing each of the following entities - Contract, Customer, Contract/ProvidedService, and Contract/ServiceAddress.

We should investigate further and find out what is the reason for this behavior