I am trying to generate the DB schema for an entity that has a
geography field (of type GeoAPI.Geometries.IGeometry - representing a
column of type 'geography' in SQL 2008).  I followed the instructions
in the "ActiveRecord Schema Generation Configuration" section of the
"Configuration and mapping" page on the NHibernate.Spatial wiki
(http://nhforge.org/wikis/spatial/configuration-and-mapping.aspx), but
it didn't work for me.

When my code called Metadata.AddMapping(cfg,
MetadataClass.SpatialReferenceSystem) (which is in the code snippet on
that page), the following exception was thrown:

NHibernate.MappingException: Resource not found:
NHibernate.Spatial.Metadata.SpatialReferenceSystem.MsSql2008SpatialDialect.hbm.xml
at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.AddResource(String path, Assembly
assembly)
at NHibernate.Spatial.Metadata.Metadata.AddMapping(Configuration
configuration, MetadataClass clazz) in C:\Projects\NHibernate.Spatial
\trunk\src\NHibernate.Spatial\src\NHibernate.Spatial\Metadata
\Metadata.cs: line 63
at ... (my code)

I'm not quite sure what "SpatialReferenceSystem" is, or why I need it,
so I tried commenting out that line of code (but left in the other
call to AddMapping which maps MetadataClass.GeometryColumn), since the
geometry column type is the only one that I really need a special
mapping for.  Unfortunately, when I call
ActiveRecordStarter.CreateSchema(), the following unhandled exception
is thrown:

MapBehavior : FailedSystem.Data.SqlClient.SqlException: There is
already an object named 'NHSP_GEOMETRY_COLUMNS' in the database.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning
(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String
methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery
(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
Boolean export, Boolean format, Boolean throwOnError, TextWriter
exportOutput, IDbCommand statement, String sql)
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
Boolean export, Boolean justDrop, Boolean format, IDbConnection
connection, TextWriter exportOutput)
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
Boolean export, Boolean justDrop, Boolean format)
NHibernate.HibernateException: There is already an object named
'NHSP_GEOMETRY_COLUMNS' in the database.
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
Boolean export, Boolean justDrop, Boolean format)
at NHibernate.Tool.hbm2ddl.SchemaExport.Create(Boolean script, Boolean
export)
at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema() in c:
\Projects\Castle\ActiveRecord\Castle.ActiveRecord\Framework
\ActiveRecordStarter.cs: line 261
Castle.ActiveRecord.Framework.ActiveRecordException: Could not create
the schema
at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema() in c:
\Projects\Castle\ActiveRecord\Castle.ActiveRecord\Framework
\ActiveRecordStarter.cs: line 265
at ...(my code)

Note that the NHSP_GEOMETRY_COLUMNS table does not exist prior to
calling CreateSchema(), but it does exist after the exception is
thrown.  Interestingly enough, it does actually create my table
correctly with the geometry column (rather than creating that column
as a 'tinyint', which was the case before I added in the
aforementioned code snippet).

Any help would be greatly appreciated.

Thank you!
Pat Gannon

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to