의미

2013-02-27 2 views
2

내 NHibernate에-DATAACCESS이 경고를 보았다 :의미

'장애인 유령 속성은 기업 때문에 위해 가져 오는 엔티티 레벨에서 게으름을 지원하지 않습니다. '

누군가가 이것을 알았습니까? 이 문제를 해결하기 위해 무엇을 바꾸어야합니까? 클래스 BusinessTypeBase의

public class BusinessTypeMap : ClassMap<BusinessType> { 
    public BusinessTypeMap() { 
     this.Table("BusinessType"); 

     this.Version(x => x.ObjectVersion); 
     this.Id(x => x.Id).GeneratedBy.Assigned(); 

     this.Map(x => x.Key).Length(8).Nullable(); 
     this.Map(x => x.Name).Length(50).Not.Nullable(); 
     this.Map(x => x.Comment).Length(8000).Nullable(); 

     this.Map(x => x.Created).Not.Nullable().Not.OptimisticLock(); 
     this.Map(x => x.CreatedBy).Length(255).Not.Nullable().Not.OptimisticLock(); 
     this.Map(x => x.Changed).Nullable().Not.OptimisticLock(); 
     this.Map(x => x.ChangedBy).Length(255).Nullable().Not.OptimisticLock(); 

     this.HasMany(x => x.LocalizedProperties).AsSet().KeyColumn("EntityId").Where("LocalizedEntityClass = 'Prayon.Entities.BusinessType'").ForeignKeyConstraintName("none").Cascade.All(); 
     this.HasMany(x => x.Companys).AsSet().KeyColumn("BusinessTypeId").Fetch.Select().Inverse().Cascade.None(); 
     this.References(x => x.Client).Column("ClientId").Fetch.Select(); 
    } 
} 

업데이트 정의 : 클래스 BusinessType의

[Serializable] 
public abstract class BusinessTypeBase : AuditableEntityBase, ILocalizedEntity { 

    #region Private Variables 

    protected String key; 
    protected String name; 
    protected String comment; 

    #endregion 

    #region Constructors 

    protected BusinessTypeBase() { 
     this.LocalizedProperties = new HashSet<LocalizedProperty>(); 

     OnCreated(); 
    } 

    protected BusinessTypeBase(Guid id, String key, String name, String comment) { 
     this.LocalizedProperties = new HashSet<LocalizedProperty>(); 

     this.id = id; 
     this.key = key; 
     this.name = name; 
     this.comment = comment; 
     OnCreated(); 
    } 

    protected BusinessTypeBase(Guid id, String name) { 
     this.LocalizedProperties = new HashSet<LocalizedProperty>(); 

     this.id = id; 
     this.name = name; 
     OnCreated(); 
    } 

    #endregion 

    #region Puplic Properties 

    public virtual String Key { 
     get { return key; } 
     set { 
      if (this.key != value) { 
       this.OnKeyChanging(value); 
       this.key = value; 
       this.OnKeyChanged(); 
      } 
     } 
    } 



    /// <summary> 
    /// @loc 
    /// </summary> 
    [Localize("Name")] 
    public virtual String Name { 
     get { return name; } 
     set { 
      if (this.name != value) { 
       this.OnNameChanging(value); 
       this.name = value; 
       this.OnNameChanged(); 
      } 
     } 
    } 

    public virtual String NameLocalized { 
     get { return this.GetLocalized(x => x.Name); } 
     set { 
      if (this.NameLocalized != value) { 
       this.OnNameLocalizedChanging(value); 
       this.AddLocalizedProperty(x => x.Name, value); 
       this.OnNameLocalizedChanged(); 
       if (string.IsNullOrEmpty(this.Name)) { 
        this.Name = value; 
       } 
      } 
     } 
    } 

    protected virtual void OnNameLocalizedChanging(String value) { 
    } 

    protected virtual void OnNameLocalizedChanged() { 
    } 



    [IgnoreForDeleteSerialization] 
    public virtual String Comment { 
     get { return comment; } 
     set { 
      if (this.comment != value) { 
       this.OnCommentChanging(value); 
       this.comment = value; 
       this.OnCommentChanged(); 
      } 
     } 
    } 



    #endregion 

    #region Version 

    protected Int32 objectVersion; 

    public virtual Int32 ObjectVersion { 
     get { return objectVersion; } 
     set { 
      if (this.objectVersion != value) { 
       this.objectVersion = value; 
      } 
     } 
    } 

    #endregion 

    #region CollectionRules 

    public override string[] CollectionRules { 
     get { return collectionRules; } 
    } 

    private static readonly string[] collectionRules = new string[] 
     { 
      "Prayon.Entities.Client.BusinessTypes" 
     }; 

    #endregion 


    #region Company Association 

    protected virtual void OnCompanysChanging(ICollection<Company> value) { 
    } 

    protected virtual void OnCompanysChanged() { 
    } 

    private ICollection<Company> companys = new HashSet<Company>(); 

    [IgnoreForDeleteSerialization] 
    public virtual ICollection<Company> Companys { 
     get { return companys; } 
     set { 
      if (this.companys != value) { 
       this.OnCompanysChanging(value); 
       this.companys = value; 
       this.OnCompanysChanged(); 

      } 

     } 
    } 

    #endregion 

    #region Client Association 

    public virtual Guid SerializableClient { 
     get { return (this.Client == null ? (this.SerializationProxies.ContainsKey("ClientId") ? this.SerializationProxies["ClientId"] : Guid.Empty) : this.Client.Id); } 
     set { this.SerializationProxies["ClientId"] = value; } 
    } 

    protected virtual void OnClientChanging(Client value) { 
    } 

    protected virtual void OnClientChanged() { 
    } 

    private Client client; 

    [IgnoreForDeleteSerialization] 
    public virtual Client Client { 
     get { return client; } 
     set { 
      if (this.client != value) { 
       this.OnClientChanging(value); 
       this.client = value; 
       this.OnClientChanged(); 
      } 
     } 
    } 

    #endregion 

    #region ICloneable Members 

    ///<summary> 
    /// Returns a Typed Copy of BusinessType 
    ///</summary> 
    public virtual object Clone() { 
     BusinessType copy = new BusinessType(); 
     copy.id = this.id; 
     copy.key = this.key; 
     copy.name = this.name; 
     copy.comment = this.comment; 
     return copy; 
    } 

    #endregion 

    #region Check Equality 

    /// <summary> 
    /// Check if the Passed Parameter is value equaled to this Address. 
    /// </summary> 
    /// <param name="obj">The Object will ba compared to.</param> 
    /// <returns>True if Equal else False</returns> 
    public override bool Equals(object obj) { 
     if (obj is BusinessTypeBase) { 
      var entity = obj as BusinessTypeBase; 
      if (entity.id != this.id) 
       return false; 
      if (entity.key != this.key) 
       return false; 
      if (entity.name != this.name) 
       return false; 
      if (entity.comment != this.comment) 
       return false; 
      return true; 
     } 
     return base.Equals(obj); 
    } 

    public override int GetHashCode() { 
     int hash = 0; 
     hash = hash^this.id.GetHashCode(); 
     if (this.key != null) { 
      hash = hash^this.key.GetHashCode(); 
     } 
     if (this.name != null) { 
      hash = hash^this.name.GetHashCode(); 
     } 
     if (this.comment != null) { 
      hash = hash^this.comment.GetHashCode(); 
     } 

     return hash; 
    } 

    public static bool operator ==(BusinessTypeBase obj1, BusinessTypeBase obj2) { 
     if (object.ReferenceEquals(obj1, null) && object.ReferenceEquals(obj2, null)) { 
      return true; 
     } 
     if (object.ReferenceEquals(obj1, null) || object.ReferenceEquals(obj2, null)) { 
      return false; 
     } 
     return obj1.Equals(obj2); 
    } 

    public static bool operator !=(BusinessTypeBase obj1, BusinessTypeBase obj2) { 
     return !(obj1 == obj2); 
    } 

    #endregion 

    #region To String 

    /// <summary> 
    /// override ToString to produce XML format of the current object 
    /// </summary> 
    public override string ToString() { 
     StringBuilder stringBuilder = new StringBuilder(); 
     stringBuilder.AppendFormat("<Id>{0}</Id>{1}", this.id.ToString(), System.Environment.NewLine); 
     if (this.key != null) 
      stringBuilder.AppendFormat("<Key>{0}</Key>{1}", this.key.ToString(), System.Environment.NewLine); 
     if (this.name != null) 
      stringBuilder.AppendFormat("<Name>{0}</Name>{1}", this.name.ToString(), System.Environment.NewLine); 
     if (this.comment != null) 
      stringBuilder.AppendFormat("<Comment>{0}</Comment>{1}", this.comment.ToString(), System.Environment.NewLine); 
     return stringBuilder.ToString(); 
    } 

    #endregion 

    #region Extensibility Method Definitions 

    protected virtual void OnCreated() { 
    } 

    protected virtual void OnKeyChanging(String value) { 
    } 

    protected virtual void OnKeyChanged() { 
    } 

    protected virtual void OnNameChanging(String value) { 
    } 

    protected virtual void OnNameChanged() { 
    } 

    protected virtual void OnCommentChanging(String value) { 
    } 

    protected virtual void OnCommentChanged() { 
    } 

    #endregion 

    #region Localization 

    public virtual ICollection<LocalizedProperty> LocalizedProperties { get; set; } 

    #endregion 
} 

업데이트 정의 :

다음

이 경고를 일으키는 기업을위한 매핑
[Serializable] 
public partial class BusinessType : BusinessTypeBase { 

    #region Constructors 

    public BusinessType() 
     : base() { 
    } 

    public BusinessType(Guid id, String key, String name, String comment) 
     : base(id, key, name, comment) { 
    } 

    public BusinessType(Guid id, String name) 
     : base(id, name) { 
    } 

    #endregion 
} 
+0

'BusinessType' 클래스는 어떻게 보이나요? 왜냐하면 나는 약간의 의문의 여지가 있기 때문에 ... –

+0

@ Trustme-I'maDoctor - 나는 전체 클래스'BusinessType'을 추가했습니다. – BennoDual

+0

고마워요.하지만 그것은'BusinessTypeBase'입니다.'BusinessType ', 명시 적으로 매핑하는 유형입니다. :) 내가 말할 필요가 있지만, 이것은 약간 중량급으로 보입니다. 저는 POCO 클래스와 매핑에 익숙해졌지만 여기서는 요점이 아닙니다. –

답변

0

*) ICollection<Company> 대신 Iesi.Collections.Generic.ISet<Company>을 사용해 보셨습니까? IIRC, Hibernate는 EF 나 다른 전형적인 라이브러리보다 다른 인터페이스를 사용했다. 일반적인 문제는 ICollection은 실제로 모든 관계가있는 "SET"동작을 나타내지 않으므로 여기서는 상당히 나쁜 계약입니다.

편집 : *) 방금 NH이 ICollection 인터페이스 (https://stackoverflow.com/a/4673125/717732)와 협조하여 잘못되었음을 알았습니다. 여전히 ISet이나 HashSet으로 시도 할 수는 있지만 문제는 미안하다 :/