Add 'geography' spatial column type support for SQL Server

Description

It appears that SQL Server 2008 has two types of spatial columns, geometry and geography, but there is no mapping setup for the geography column type in the SQL Server dialect so tables with geography columns types are not being noticed as containing geometry.

Updating the registerSqlTypeNameToClassMappings method in the SQLServerDialect class fixes the problem

@Override
public void registerSqlTypeNameToClassMappings(
Map<String, Class<?>> mappings)
{
super.registerSqlTypeNameToClassMappings(mappings);

mappings.put( "geometry", Geometry.class );
mappings.put( "geography", Geometry.class );

// also add support nchar and nvarchar
mappings.put( "nchar", String.class);
mappings.put( "nvarchar", String.class);
}

Environment

None

Activity

codehaus 
April 10, 2015 at 3:05 PM

CodeHaus Comment From: sforbes - Time: Thu, 24 Jun 2010 04:25:14 -0500
---------------------
As an added bonus the geography spatial column type doesn't support the .STEnvelope() method, so the SQL generated for bounds calculations need to be redone.

<a href="http://blogs.msdn.com/b/davidlean/archive/2008/10/27/sql-2008-spatial-samples-part-n-3-of-n-performance-improvement-methods.aspx">http://blogs.msdn.com/b/davidlean/archive/2008/10/27/sql-2008-spatial-samples-part-n-3-of-n-performance-improvement-methods.aspx</a>

codehaus 
April 10, 2015 at 3:05 PM

CodeHaus Comment From: sforbes - Time: Tue, 22 Jun 2010 21:09:07 -0500
---------------------
Looks like it may not be that simple, according to <a href="http://conceptdev.blogspot.com/2007/12/sql-server-2008-geography-vs-geometry.html">http://conceptdev.blogspot.com/2007/12/sql-server-2008-geography-vs-geometry.html</a> the SQL generated to retrieve the geometry may need to be different for the two column types.

Details

Assignee

Reporter

Affects versions

Priority

Created June 22, 2010 at 6:04 AM
Updated August 29, 2016 at 5:46 PM