ActiveRecord에 몇 가지 문제가 있습니다.ActiveRecord 및 NHibernate Spatial
모두 정상적으로 작동하지만 가끔씩 작동합니다. 항상 그렇지는 않아.
공간 엔티티가 포함 된 프로젝트에서 참조되는 MVC 페이지로 이동하려고하면이 엔티티에는 공간 유형이 없습니다.이 예외는 발생합니다.
은 { "A GeometryType 열 선언되었지만, 공간적 구성 방언 없다"}
올바르게 구성 방언이된다. Xml과 InPlace의 두 가지 방법으로 구성하려고했습니다.
이 내 시작 방법 :
public static void StartActiveRecord()
{
IDictionary<string,string> hash = new Dictionary<string,string>();
hash.Add("isWeb", "true");
hash.Add("connection.driver_class","NHibernate.Driver.NpgsqlDriver");
hash.Add("connection.connection_string","Server=localhost;Port=5432;database=nhiber;User ID=postgres;Password=pass;");
hash.Add("connection.provider","NHibernate.Connection.DriverConnectionProvider");
hash.Add("dialect","NHibernate.Spatial.Dialect.PostGisDialect,NHibernate.Spatial.PostGis");
hash.Add("proxyfactory.factory_class","NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
InPlaceConfigurationSource source = new InPlaceConfigurationSource();
source.Add(typeof(ActiveRecordBase), hash);
ActiveRecordStarter.Initialize(source, GetActiveRecordTypes());
foreach (Configuration cfg in ActiveRecordMediator.GetSessionFactoryHolder().GetAllConfigurations())
{
cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));
//Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);
//Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);
}
}
그리고 이것은이 오류는 종종 발생 Global.asax에
protected void Application_Start()
{
Ignition.StartActiveRecord();
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
에, 나의 시작 방법입니다. dev 서버를 죽이면 가끔은 괜찮아 지지만 나중에 몇 단계 만 다시 충돌합니다.
HELP!
편집 : 방언있을 때 내가 Global.asax에()를 Ignition.StartActiveRecord,이 오류를 이것에 매핑 및 다른 정보
을 추가 해요. dialect가 없다면 ActiveRecordStarter.Initialize();에 오류가 발생합니다.
아래에 매핑 된이 개체는 전체 어셈블리에서 유일한 공간 인식 개체입니다.
public class Complaint:ActiveRecordBase<Complaint>
{
[PrimaryKey(Column="complaint_id",Generator=PrimaryKeyType.Sequence,SequenceName="complaint_seq")]
public virtual int ComplaintId { get; set; }
[Property(Column="date_of_complaint",NotNull=true)]
public virtual DateTime DateOfComplaint { get; set; }
[Property(Column="description",Length=256,NotNull=true)]
public virtual string Description { get; set; }
[Property(Column="complaint_status",NotNull=true,Default="1")]
public cityzenComplaintStatus Status { get; set; }
[BelongsTo(Column = "complaint_type_id")]
public ComplaintType Type { get; set; }
[Property("the_geom", ColumnType = "NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial")]
public virtual IGeometry Geometry { get; set; }
[OneToOne(ForeignKey="official_answer_id")]
public virtual OfficialAnswer CityAnswer { get; set; }
[BelongsTo("user_id", Fetch = FetchEnum.Select, Lazy = FetchWhen.OnInvoke, Update = false, NotNull = true)]
public virtual CityzenUser User { get; set; }
[HasMany(typeof(Vote),Table="vote",ColumnKey="complaint_id",RelationType=RelationType.Set,Inverse=true)]
public virtual IList<Vote> Votes { get; set; }
[HasMany(typeof(Comment),Table="comment",ColumnKey="complaint_id",RelationType=RelationType.Set,Inverse=true)]
public virtual IList<Comment> Comments { get; set; }
[Property(Column = "deleted", Default = "false", NotNull = true)]
public virtual bool Deleted { get; set; }
}
는 구성의 특정 라인 밖으로 걸릴 때이 문제를 재현 할 수 있습니까? hash.Add ("dialect", "NHibernate.Spatial.Dialect.PostGisDialect, NHibernate.Spatial.PostGis"); –
나는 방언이 구성되어 있지 않다는 예외를 던질 것이라고 확신한다.시도해 볼게. –
내가 말한 라인을 제거하면 ActiveRecordStarter.Initialize를 시도 할 때 "구성에서 방언을 찾을 수 없습니다"라는 메시지가 나타납니다. –