Skip to content

Commit

Permalink
[GEOT-4428] Make native paging optional in sql server, patch by Stewa…
Browse files Browse the repository at this point in the history
…rt Loving-Gibbard
  • Loading branch information
aaime committed Mar 28, 2013
1 parent 955f972 commit a0e74f2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Expand Up @@ -40,7 +40,10 @@ public class SQLServerDataStoreFactory extends JDBCDataStoreFactory {

/** parameter for using integrated security, only works on windows, ignores the user and password parameters, the current windows user account is used for login*/
public static final Param INTSEC = new Param("Integrated Security", Boolean.class, "Login as current windows user account. Works only in windows. Ignores user and password settings.", false, new Boolean(false));


/** parameter for using Native Paging */
public static final Param NATIVE_PAGING = new Param("Use Native Paging", Boolean.class, "Use native paging for sql queries. For some sets of data, native paging can have a performance impact.", false, Boolean.TRUE);

/** Metadata table providing information about primary keys **/
public static final Param GEOMETRY_METADATA_TABLE = new Param("Geometry metadata table", String.class,
"The optional table containing geometry metadata (geometry type and srid). Can be expressed as 'schema.name' or just 'name'", false);
Expand Down Expand Up @@ -76,6 +79,7 @@ protected void setupParameters(Map parameters) {
super.setupParameters(parameters);
parameters.put(DBTYPE.key, DBTYPE);
parameters.put(INTSEC.key, INTSEC);
parameters.put(NATIVE_PAGING.key, NATIVE_PAGING);
parameters.put(GEOMETRY_METADATA_TABLE.key, GEOMETRY_METADATA_TABLE);
}

Expand Down Expand Up @@ -107,6 +111,10 @@ protected JDBCDataStore createDataStoreInternal(JDBCDataStore dataStore, Map par
// check the geometry metadata table
String metadataTable = (String) GEOMETRY_METADATA_TABLE.lookUp(params);
dialect.setGeometryMetadataTable(metadataTable);

// check native paging
Boolean useNativePaging = (Boolean) NATIVE_PAGING.lookUp(params);
dialect.setUseOffSetLimit(useNativePaging == null || Boolean.TRUE.equals(useNativePaging));

return dataStore;
}
Expand Down
Expand Up @@ -76,6 +76,9 @@ public class SQLServerDialect extends BasicSQLDialect {
* @param dataStore
*/
private String geometryMetadataTable;


private Boolean useOffsetLimit = false;

final static Map<String, Class> TYPE_TO_CLASS_MAP = new HashMap<String, Class>() {
{
Expand Down Expand Up @@ -556,7 +559,7 @@ protected void encodeTableName(String schemaName, String tableName, StringBuffer

@Override
public boolean isLimitOffsetSupported() {
return true;
return useOffsetLimit;
}

@Override
Expand Down Expand Up @@ -626,4 +629,12 @@ public void setGeometryMetadataTable(String geometryMetadataTable) {
this.geometryMetadataTable = geometryMetadataTable;
}

/**
* Sets whether to use offset limit or not
* @param useOffsetLimit
*/
public void setUseOffSetLimit(Boolean useOffsetLimit) {
this.useOffsetLimit = useOffsetLimit;
}

}
Expand Up @@ -43,6 +43,7 @@ public SQLServerJNDIDataStoreFactory() {
protected void setupParameters(Map parameters) {
super.setupParameters(parameters);
parameters.put(INTSEC.key, INTSEC);
parameters.put(NATIVE_PAGING.key, NATIVE_PAGING);
parameters.put(GEOMETRY_METADATA_TABLE.key, GEOMETRY_METADATA_TABLE);
}
}

0 comments on commit a0e74f2

Please sign in to comment.