private static InheritanceType.Type DoGetForSubclass(Subclass subclass) { if (subclass is SingleTableSubclass) { return InheritanceType.Type.SINGLE; } else if (subclass is JoinedSubclass) { return InheritanceType.Type.JOINED; } else if (subclass is UnionSubclass) { return InheritanceType.Type.TABLE_PER_CLASS; } throw new MappingException("Unknown subclass class: " + subclass.ClassName); }
/// <summary> /// Adds a <see cref="Subclass"/> to the class hierarchy. /// </summary> /// <param name="subclass">The <see cref="Subclass"/> to add to the hierarchy.</param> public virtual void AddSubclass(Subclass subclass) { // Inheritable cycle detection (paranoid check) PersistentClass superclass = Superclass; while (superclass != null) { if (subclass.Name == superclass.Name) { throw new MappingException(string.Format("Circular inheritance mapping detected: {0} will have itself as superclass when extending {1}", subclass.Name, Name)); } superclass = superclass.Superclass; } subclasses.Add(subclass); }
private static InheritanceType DoGetForSubclass(Subclass subclass) { if (subclass is SingleTableSubclass) { return InheritanceType.Single; } if (subclass is JoinedSubclass) { return InheritanceType.Joined; } if (subclass is UnionSubclass) { return InheritanceType.TablePerClass; } throw new MappingException("Unknown subclass class: " + (subclass != null ? subclass.GetType().FullName : "Not available type.")); }
/// <summary> /// Adds a <see cref="Subclass"/> to the class hierarchy. /// </summary> /// <param name="subclass">The <see cref="Subclass"/> to add to the hierarchy.</param> public virtual void AddSubclass(Subclass subclass) { // Inheritable cycle detection (paranoid check) PersistentClass superclass = Superclass; while (superclass != null) { if (subclass.EntityName.Equals(superclass.EntityName)) { throw new MappingException( string.Format("Circular inheritance mapping detected: {0} will have itself as superclass when extending {1}", subclass.EntityName, EntityName)); } superclass = superclass.Superclass; } subclasses.Add(subclass); }
/// <summary> /// Adds a <see cref="Subclass"/> to the class hierarchy. /// </summary> /// <param name="subclass">The <see cref="Subclass"/> to add to the hierarchy.</param> /// <remarks> /// When a <see cref="Subclass"/> is added this mapped class has the property <see cref="IsPolymorphic"/> /// set to <see langword="true" />. /// </remarks> public override void AddSubclass(Subclass subclass) { base.AddSubclass(subclass); polymorphic = true; }
public static void BindJoinedSubclass( XmlNode node, Subclass model, Mappings mappings ) { BindClass( node, model, mappings ); // joined subclass if( model.ClassPersisterClass == null ) { model.RootClazz.ClassPersisterClass = typeof( NormalizedEntityPersister ); } //table + schema names XmlAttribute schemaNode = node.Attributes[ "schema" ]; string schema = schemaNode == null ? mappings.SchemaName : schemaNode.Value; Table mytable = mappings.AddTable( schema, GetClassTableName( model, node, mappings ) ); model.Table = mytable; log.Info( "Mapping joined-subclass: " + model.Name + " -> " + model.Table.Name ); XmlNode keyNode = node.SelectSingleNode( nsKey, nsmgr ); SimpleValue key = new SimpleValue( mytable ); model.Key = key; BindSimpleValue( keyNode, key, false, model.Name, mappings ); model.Key.Type = model.Identifier.Type; model.CreatePrimaryKey( dialect ); model.CreateForeignKey(); // CHECK XmlAttribute chNode = node.Attributes[ "check" ]; if( chNode != null ) { mytable.AddCheckConstraint( chNode.Value ); } // properties PropertiesFromXML( node, model, mappings ); }
public static void BindSubclass( XmlNode node, Subclass model, Mappings mappings ) { BindClass( node, model, mappings ); if( model.ClassPersisterClass == null ) { model.RootClazz.ClassPersisterClass = typeof( EntityPersister ); } model.Table = model.Superclass.Table; log.Info( "Mapping subclass: " + model.Name + " -> " + model.Table.Name ); // properties PropertiesFromXML( node, model, mappings ); }
private static void HandleSubclass( PersistentClass model, Mappings mappings, XmlNode subnode ) { Subclass subclass = new Subclass( model ); BindSubclass( subnode, subclass, mappings ); model.AddSubclass( subclass ); mappings.AddClass( subclass ); }