/**
   * Build a map of logical to physical names for use in Orm Updates for a given descriptor.
   *
   * <p>This includes the dbWrite scalar properties and imported foreign key properties.
   */
  public static Map<String, String> build(BeanDescriptor<?> descriptor) {

    Map<String, String> deployMap = new HashMap<String, String>();

    String shortName = descriptor.getName();
    String beanName = shortName.toLowerCase();
    deployMap.put(beanName, descriptor.getBaseTable());

    BeanProperty[] baseScalar = descriptor.propertiesBaseScalar();
    for (BeanProperty baseProp : baseScalar) {
      // excluding formula, secondary table properties
      if (baseProp.isDbInsertable() || baseProp.isDbUpdatable()) {
        deployMap.put(baseProp.getName().toLowerCase(), baseProp.getDbColumn());
      }
    }

    BeanPropertyAssocOne<?>[] oneImported = descriptor.propertiesOneImported();
    for (BeanPropertyAssocOne<?> assocOne : oneImported) {

      ImportedId importedId = assocOne.getImportedId();
      if (importedId == null) {
        String m =
            descriptor.getFullName()
                + " importedId is null for associated: "
                + assocOne.getFullBeanName();
        logger.log(Level.SEVERE, m);

      } else if (importedId.isScalar()) {
        deployMap.put(importedId.getLogicalName(), importedId.getDbColumn());
      }
    }

    return deployMap;
  }
  private String tableAliasIntern(
      BeanDescriptor<?> descriptor, String s, boolean dbEncrypted, String dbColumn) {
    if (descriptor != null) {
      s = StringHelper.replaceString(s, "${ta}.", "${}");
      s = StringHelper.replaceString(s, "${ta}", "${}");

      if (dbEncrypted) {
        s = dbEncryptFunction.getDecryptSql(s);
        String namedParam = ":encryptkey_" + descriptor.getBaseTable() + "___" + dbColumn;
        s = StringHelper.replaceString(s, "?", namedParam);
      }
    }
    return InternString.intern(s);
  }
 /** 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());
 }