/** * 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; }
/** * Create a Matching BeanProperty with some attributes overridden. * * <p>Primarily for supporting Embedded beans with overridden dbColumn mappings. */ public BeanProperty(BeanProperty source, BeanPropertyOverride override) { this.descriptor = source.descriptor; this.name = InternString.intern(source.getName()); this.propertyIndex = source.propertyIndex; this.dbColumn = InternString.intern(override.getDbColumn()); // override with sqlFormula not currently supported this.sqlFormulaJoin = null; this.sqlFormulaSelect = null; this.formula = false; this.excludedFromHistory = source.excludedFromHistory; this.draft = source.draft; this.draftDirty = source.draftDirty; this.draftOnly = source.draftOnly; this.draftReset = source.draftReset; this.softDelete = source.softDelete; this.softDeleteDbSet = source.softDeleteDbSet; this.softDeleteDbPredicate = source.softDeleteDbPredicate; this.fetchEager = source.fetchEager; this.unidirectionalShadow = source.unidirectionalShadow; this.discriminator = source.discriminator; this.localEncrypted = source.isLocalEncrypted(); this.isTransient = source.isTransient(); this.secondaryTable = source.isSecondaryTable(); this.secondaryTableJoin = source.secondaryTableJoin; this.secondaryTableJoinPrefix = source.secondaryTableJoinPrefix; this.dbComment = source.dbComment; this.dbBind = source.getDbBind(); this.dbEncrypted = source.isDbEncrypted(); this.dbEncryptedType = source.getDbEncryptedType(); this.dbEncryptFunction = source.dbEncryptFunction; this.dbRead = source.isDbRead(); this.dbInsertable = source.isDbInsertable(); this.dbUpdatable = source.isDbUpdatable(); this.nullable = source.isNullable(); this.unique = source.isUnique(); this.naturalKey = source.isNaturalKey(); this.dbLength = source.getDbLength(); this.dbScale = source.getDbScale(); this.dbColumnDefn = InternString.intern(source.getDbColumnDefn()); this.dbColumnDefault = source.dbColumnDefault; this.inherited = source.isInherited(); this.owningType = source.owningType; this.local = owningType.equals(descriptor.getBeanType()); this.version = source.isVersion(); this.embedded = source.isEmbedded(); this.id = source.isId(); this.generatedProperty = source.getGeneratedProperty(); this.getter = source.getter; this.setter = source.setter; this.dbType = source.getDbType(true); this.scalarType = source.scalarType; this.lob = isLobType(dbType); this.propertyType = source.getPropertyType(); this.field = source.getField(); this.docOptions = source.docOptions; this.elPlaceHolder = override.replace(source.elPlaceHolder, source.dbColumn); this.elPlaceHolderEncrypted = override.replace(source.elPlaceHolderEncrypted, source.dbColumn); this.jsonSerialize = source.jsonSerialize; this.jsonDeserialize = source.jsonDeserialize; }