private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table) { if (timestampSchema == null) return; string propertyName = timestampSchema.name; SimpleValue simpleValue = new SimpleValue(table); BindColumns(timestampSchema, simpleValue, propertyName); if (!simpleValue.IsTypeSpecified) simpleValue.TypeName = NHibernateUtil.Timestamp.Name; Mapping.Property property = new Mapping.Property(simpleValue); BindProperty(timestampSchema, property); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make // sure... if (property.Generation == PropertyGeneration.Insert) throw new MappingException("'generated' attribute cannot be 'insert' for versioning property"); simpleValue.NullValue = timestampSchema.unsavedvalue; rootClass.Version = property; rootClass.AddProperty(property); }
private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas) { if (timestampSchema == null) return; string propertyName = timestampSchema.name; SimpleValue simpleValue = new SimpleValue(table); BindColumns(timestampSchema, simpleValue, propertyName); if (!simpleValue.IsTypeSpecified) { switch (timestampSchema.source) { case HbmTimestampSource.Vm: simpleValue.TypeName = NHibernateUtil.Timestamp.Name; break; case HbmTimestampSource.Db: simpleValue.TypeName = NHibernateUtil.DbTimestamp.Name; break; default: simpleValue.TypeName = NHibernateUtil.Timestamp.Name; break; } } var property = new Property(simpleValue); BindProperty(timestampSchema, property, inheritedMetas); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make // sure... if (property.Generation == PropertyGeneration.Insert) throw new MappingException("'generated' attribute cannot be 'insert' for versioning property"); simpleValue.NullValue = timestampSchema.unsavedvalue == HbmTimestampUnsavedvalue.Null ? null : "undefined"; rootClass.Version = property; rootClass.AddProperty(property); }
private void BindProperty(HbmTimestamp timestampSchema, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { property.Name = timestampSchema.name; if (property.Value.Type == null) throw new MappingException("could not determine a property type for: " + property.Name); property.PropertyAccessorName = timestampSchema.access ?? mappings.DefaultAccess; property.Cascade = mappings.DefaultCascade; property.IsUpdateable = true; property.IsInsertable = true; property.IsOptimisticLocked = true; property.Generation = Convert(timestampSchema.generated); if (property.Generation == PropertyGeneration.Always || property.Generation == PropertyGeneration.Insert) { // generated properties can *never* be insertable... if (property.IsInsertable) // insertable simply because that is the user did not specify // anything; just override it property.IsInsertable = false; // properties generated on update can never be updateable... if (property.IsUpdateable && property.Generation == PropertyGeneration.Always) // updateable only because the user did not specify // anything; just override it property.IsUpdateable = false; } property.MetaAttributes = GetMetas(timestampSchema, inheritedMetas); property.LogMapped(log); }
private void BindColumns(HbmTimestamp timestampSchema, SimpleValue model, string propertyPath) { Table table = model.Table; if (timestampSchema.column != null) { Column col = new Column(); col.Value = model; BindColumn(col, false); col.Name = mappings.NamingStrategy.ColumnName(timestampSchema.column); if (table != null) table.AddColumn(col); model.AddColumn(col); } if (model.ColumnSpan == 0) { Column col = new Column(); col.Value = model; BindColumn(col, false); col.Name = mappings.NamingStrategy.PropertyToColumnName(propertyPath); model.Table.AddColumn(col); model.AddColumn(col); } }