dimanche 2 août 2015

NHibernate infers incorrect type on property in hbm file

I have an existing HBM XML file to which I need to add two new properties. When I add these, NHibernate appears to infer incorrect type and reports PropertyAccessException. Explicitly setting the property also doesn't help. Code below:

Domain:

public class Centre : VersionedDomainObject
{
    public virtual DateTime? DateDeleted { get; set; }
    public virtual bool Deleted { get; set; }

    public virtual string CentreName { get; set; }
    public virtual string CentreNumber { get; set; }

    public virtual Iesi.Collections.Generic.ISet<CentreAddress> Addresses { get; set; }
    public virtual Iesi.Collections.Generic.ISet<CentreSource> CentreSources { get; set; }



    public virtual string Telephone { get; set; }
    public virtual string Fax { get; set; }
    public virtual string Url { get; set; }
    public virtual string Email { get; set; }
    public virtual bool CentreVisibleOptIn { get; set; }
    public virtual decimal? Latitude { get; set; }
    public virtual decimal? Longitude { get; set; }
...

}

HBM XML File:

<id name="Id" access="property" column="ID">
  <generator class="identity" />
</id>

<version name="_version" column="VERSION" unsaved-value="-1"  access="field"/>

<property name="LastAmended" not-null="true"/>
<property name="DateCreated" not-null="true"/>

<property name="DateDeleted" />
<property name="Deleted" />

<property name="CentreName" />
<property name="CentreNumber" />

<property name="Telephone"  />
<property name="Fax" />
<property name="Url" />
<property name="Email" />

<property name="CentreVisibleOptIn" not-null="true" />
<property name="AcceptsPrivateCandidates"/>

<property name="Contact" />

<property name="AwardingOrganisationId" not-null="true"/>

<many-to-one name="GeographicRegion" class="CommonData.Domain.Common.Location.GeographicRegion, CommonData.Domain.Common" column="GeographicRegionId" />

<many-to-one name="CategoryType" column="CategoryTypeId" class="CommonData.Domain.Centre.CategoryType, CommonData.Domain.Common.Operational" />

<property name="Latitude" />
<property name="Longitude" />

<set name="Addresses" cascade="all-delete-orphan" lazy="true" inverse="true">
  <key column="CentreId" not-null="true" />
  <one-to-many class="CommonData.Domain.Centre.CentreAddress, CommonData.Domain.Centre"/>
</set>

<set name="CentreSources" cascade="all-delete-orphan" lazy="true" inverse="true">
  <key column="CentreId" not-null="true" />
  <one-to-many class="CommonData.Domain.Centre.CentreSource, CommonData.Domain.Centre"/>
</set>

Database:

Latitude and Longitude are newly added columns in database with type decimal(9,6).

Aucun commentaire:

Enregistrer un commentaire