Can you submit your change as a pull request please, we have contributing
guidelines online for participation in the project covering what is needed.

In the specific case of SQLServer not many developers have access to a
database to test against. I know I do not …

Jody

On Mon, Dec 13, 2021 at 1:10 PM acefael <e...@acefael.es> wrote:

> hi,
>
> the default implementation of SQLDialect returns null for any invocation
> of getNextSequenceValue and SQLServerDialect does not override that.
> Therefore using GT_PK_METADATA with pk_policy 'sequence' will never work.
> Could anyone with enough access apply my implementation of
> getNextSequenceValue to SQLServerDialect ?
>
> My implementation
>
>     @Override
>     public Object getNextSequenceValue(String schemaName, String
> sequenceName, Connection cx)
>             throws SQLException {
>          Statement st = cx.createStatement();
>          try {
>              ResultSet rs =
>                  st.executeQuery( "SELECT NEXT VALUE FOR " + sequenceName
> );
>              try {
>                  if (!rs.next()) {
>                      throw new SQLException("Could not find next sequence
> value");
>                  }
>                  return rs.getInt(1);
>              } finally {
>                  dataStore.closeSafe(rs);
>              }
>         } finally {
>             dataStore.closeSafe(st);
>         }
>     }
>
> This is basically the method copied from the oracle-dialect and with the
> sql modified to work with sqlserver.  Using getInt instead of getLong is
> asking for trouble, imo, but you probably had your reasons.
>
> yours
> acefael
>
>
>
>
>
>
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
-- 
--
Jody Garnett
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to