NHibernate.Spatial.MySQL: Null geometries and "No persister for: GeoAPI.Geometries.IGeometry" error -
i attempting create simple demo solution using nhibernate.spatial.mysql (version 4.0.4.4001). solution available here: https://github.com/andrerav/nhibernate.spatial.mysql.demo
the mapping seems work @ least inserts -- demodataimport project able read geojson files, , insert geometries database, , can verify results using mysql workbench.
however, if query data, geometries show null values. furthermore, if perform query such this:
var municipalities = sessionmanager.session.query<municipality>() .where(m => m.area.within(county.area)).tolist();
i exception says "no persister for: geoapi.geometries.igeometry".
any ideas wrong?
to run solution, first create mysql database (mysql 5.7 or newer) called mysqldemo username/password mysqldemo/mysqldemo. demodataimport project dump geojson data database, , demoqueryutil project can used execute queries.
mapping:
public class municipality { public virtual int id { get; set; } public virtual county county { get; set; } public virtual string name { get; set; } public virtual int municipalityno { get; set; } public virtual igeometry area { get; set; } } public class municipalitymap : classmap<municipality> { public municipalitymap() { importtype<igeometry>(); id(x => x.id); map(x => x.name); map(x => x.municipalityno); map(x => x.area).customtype<mysqlgeometrytype>(); references(x => x.county).nullable(); } } public class county { public virtual int id { get; set; } public virtual string name { get; set; } public virtual int countyno { get; set; } public virtual igeometry area { get; set; } public virtual list<municipality> municipalities { get; set; } } public class countymap : classmap<county> { public countymap() { importtype<igeometry>(); id(x => x.id); map(x => x.name); map(x => x.countyno); map(x => x.area).customtype<mysqlgeometrytype>(); } }
configuration:
public static void configure(bool generatetables = false) { var cfg = fluently.configure() .database(fluentnhibernate.cfg.db.mysqlconfiguration.standard .connectionstring(c => c.fromconnectionstringwithkey("mysql")) .driver<mysqldatadriver>() .showsql() .dialect<mysqlspatialdialect>()) .mappings(x => x.fluentmappings.addfromassemblyof<municipalitymap>()) .buildconfiguration(); cfg.addauxiliarydatabaseobject(new spatialauxiliarydatabaseobject(cfg)); if (generatetables) { var exporter = new schemaexport(cfg); exporter.drop(false, true); exporter.create(true, true); } sessionmanager.sessionfactory = cfg.buildsessionfactory(); }
example query:
var county = sessionmanager.session.query<county>().first();
this problem due lack of support mysql 5.7 in nhibernate.spatial.mysql. have added new mysql57spatialdialect in prerelease version of nhibernate.spatial.mysql, fixes problem.
Comments
Post a Comment