/** Add appropriate cache changes to support delete bean. */
 void handleDelete(Object id, PersistRequestBean<T> deleteRequest, CacheChangeSet changeSet) {
   queryCacheClear(changeSet);
   if (beanCache != null) {
     changeSet.addBeanRemove(desc, id);
   }
   cacheDeleteImported(true, deleteRequest.getEntityBean(), changeSet);
 }
  /** Add appropriate changes to support update. */
  void handleUpdate(Object id, PersistRequestBean<T> updateRequest, CacheChangeSet changeSet) {

    queryCacheClear(changeSet);

    if (beanCache == null) {
      // query caching only
      return;
    }

    List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.getUpdatedManyCollections();
    if (manyCollections != null) {
      for (BeanPropertyAssocMany<?> many : manyCollections) {
        Object details = many.getValue(updateRequest.getEntityBean());
        CachedManyIds entry = createManyIds(many, details);
        if (entry != null) {
          changeSet.addManyPut(desc, many.getName(), id, entry);
        }
      }
    }

    // check if the bean itself was updated
    if (!updateRequest.isUpdatedManysOnly()) {

      boolean updateNaturalKey = false;

      Map<String, Object> changes = new LinkedHashMap<>();
      EntityBean bean = updateRequest.getEntityBean();
      boolean[] dirtyProperties = updateRequest.getDirtyProperties();
      for (int i = 0; i < dirtyProperties.length; i++) {
        if (dirtyProperties[i]) {
          BeanProperty property = desc.propertiesIndex[i];
          if (property.isCacheDataInclude()) {
            Object val = property.getCacheDataValue(bean);
            changes.put(property.getName(), val);
            if (property.isNaturalKey()) {
              updateNaturalKey = true;
              changeSet.addNaturalKeyPut(desc, id, val);
            }
          }
        }
      }

      changeSet.addBeanUpdate(desc, id, changes, updateNaturalKey, updateRequest.getVersion());
    }
  }
 /** Add appropriate cache changes to support insert. */
 void handleInsert(PersistRequestBean<T> insertRequest, CacheChangeSet changeSet) {
   queryCacheClear(changeSet);
   cacheDeleteImported(false, insertRequest.getEntityBean(), changeSet);
   changeSet.addBeanInsert(desc.getBaseTable());
 }