Ejemplo n.º 1
0
        // ===============================================================================
        //                                                                          Finder
        //                                                                          ======
        public ColumnInfo FindLocalByForeign(String foreignColumnDbName)
        {
            ColumnInfo keyColumnInfo    = _foreignDBMeta.FindColumnInfo(foreignColumnDbName);
            ColumnInfo resultColumnInfo = _foreignLocalColumnInfoMap.get(keyColumnInfo);

            if (resultColumnInfo == null)
            {
                String msg = "Not found by foreignColumnDbName in _foreignLocalColumnInfoMap:";
                msg = msg + " foreignColumnDbName=" + foreignColumnDbName + " foreignLocalColumnInfoMap=" + _foreignLocalColumnInfoMap;
                throw new ArgumentException(msg);
            }
            return(resultColumnInfo);
        }
Ejemplo n.º 2
0
        public ColumnInfo FindReferrerByLocal(String localColumnDbName)
        {
            ColumnInfo keyColumnInfo    = localDBMeta.FindColumnInfo(localColumnDbName);
            ColumnInfo resultColumnInfo = (ColumnInfo)localReferrerColumnInfoMap.get(keyColumnInfo);

            if (resultColumnInfo == null)
            {
                String msg = "Not found by localColumnDbName in localReferrerColumnInfoMap:";
                msg = msg + " localColumnDbName=" + localColumnDbName + " localReferrerColumnInfoMap=" + localReferrerColumnInfoMap;
                throw new ArgumentException(msg);
            }
            return(resultColumnInfo);
        }
Ejemplo n.º 3
0
        // ===============================================================================
        //                                                                          Finder
        //                                                                          ======
        public ColumnInfo FindLocalByReferrer(String referrerColumnDbName)
        {
            ColumnInfo keyColumnInfo    = referrerDBMeta.FindColumnInfo(referrerColumnDbName);
            ColumnInfo resultColumnInfo = (ColumnInfo)referrerLocalColumnInfoMap.get(keyColumnInfo);

            if (resultColumnInfo == null)
            {
                String msg = "Not found by referrerColumnDbName in referrerLocalColumnInfoMap:";
                msg = msg + " referrerColumnDbName=" + referrerColumnDbName + " referrerLocalColumnInfoMap=" + referrerLocalColumnInfoMap;
                throw new ArgumentException(msg);
            }
            return(resultColumnInfo);
        }
        /**
         * @param cb Condition-bean. (NotNull)
         * @param entity Entity. (NotNull)
         * @return The two-way SQL of query update. (NullAllowed: If the set of modified properties is empty, return null.)
         */
        protected String buildQueryUpdateTwoWaySql(ConditionBean cb, Entity entity)
        {
            Map <String, String> columnParameterMap = new LinkedHashMap <String, String>();
            DBMeta dbmeta = DBMetaInstanceHandler.FindDBMeta(entity.TableDbName);

            System.Collections.Generic.IDictionary <String, Object> modifiedPropertyNames = entity.ModifiedPropertyNames;
            if (modifiedPropertyNames.Count == 0)
            {
                return(null);
            }
            String currentPropertyName = null;

            foreach (String propertyName in modifiedPropertyNames.Keys)
            {
                currentPropertyName = propertyName;
                ColumnInfo   columnInfo = dbmeta.FindColumnInfo(propertyName);
                String       columnName = columnInfo.ColumnDbName;
                PropertyInfo getter     = columnInfo.FindProperty();
                Object       value      = getter.GetValue(entity, null);
                if (value != null)
                {
                    columnParameterMap.put(columnName, "/*entity." + propertyName + "*/null");
                }
                else
                {
                    columnParameterMap.put(columnName, "null");
                }
            }
            if (dbmeta.HasVersionNo)
            {
                ColumnInfo columnInfo = dbmeta.VersionNoColumnInfo;
                String     columnName = columnInfo.ColumnDbName;
                columnParameterMap.put(columnName, columnName + " + 1");
            }
            if (dbmeta.HasUpdateDate)
            {
                ColumnInfo   columnInfo = dbmeta.UpdateDateColumnInfo;
                PropertyInfo setter     = columnInfo.FindProperty();
                setter.SetValue(entity, DateTime.Now, null);
                String columnName = columnInfo.ColumnDbName;
                columnParameterMap.put(columnName, "/*entity." + columnInfo.PropertyName + "*/null");
            }
            return(cb.SqlClause.getClauseQueryUpdate(columnParameterMap));
        }
        protected IPropertyType CreatePropertyTypeExtension(PropertyInfo pi, DBMeta dbmeta)
        {
            if (IsRelationProperty(pi, dbmeta))
            {
                return(null);
            }
            String        columnName = GetPropertyTypeColumnName(pi);
            IValueType    valueType  = ValueTypes.GetValueType(pi.PropertyType);
            IPropertyType pt         = new PropertyTypeImpl(pi, valueType, columnName);

            if (dbmeta.HasPrimaryKey && dbmeta.HasColumn(pt.ColumnName))
            {
                if (dbmeta.FindColumnInfo(pt.ColumnName).IsPrimary)
                {
                    pt.IsPrimaryKey = true;
                }
            }
            pt.IsPersistent = IsPersistentProperty(pi, dbmeta);
            return(pt);
        }