ActiveRecord and NHibernate Spatial -
i'm having problems activerecord.
well works fine, it's working sometimes. not time.
when try navigate mvc page referenced in project contains spatial entity (theres 1 spatial entity - , entity not have spatial type) exception.
{"a geometrytype column has been declared, there no spatial dialect configured"}
there dialect correctly configured. i've tried configurate in 2 ways: xml , inplace.
this startup method:
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); } }
and startup method, in global.asax
protected void application_start() { ignition.startactiverecord(); arearegistration.registerallareas(); registerroutes(routetable.routes); }
this error occurs sometimes. killing dev server makes ok, crash again few steps later.
help!
edit: i'm adding mappings , other info
when there dialect, errors out in ignition.startactiverecord() on global.asax. when there no dialect errors out in activerecordstarter.initialize();
just sure, object mapped below spatial aware object in entire assembly.
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; } }
your configuration looks right me whatever reason whenever nh instantiates instance of geometrytype cannot find dialect configured use knows type of igeometry need initialize (postgisgeometrytype in case).
what may able temporary workaround declare member variable this:
[property("the_geom", columntype = "nhibernate.spatial.type.postgisgeometrytype, nhibernate.spatial.postgis")] public virtual igeometry geometry { get; set; }
if find else out post here.
Comments
Post a Comment