Consistent incrementer arrangement for PostgreSQL, DB2 and SAP HANA

Includes related polishing in core.metadata and datasource.embedded and a revision of the corresponding database definitions in sql-error-codes.

Issue: SPR-16558

(cherry picked from commit 82515a3)
This commit is contained in:
Juergen Hoeller
2018-03-06 13:36:15 +01:00
parent b643f7836c
commit 0962c66592
30 changed files with 446 additions and 189 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,12 +63,12 @@ public class CallMetaDataProviderFactory {
/**
* Create a CallMetaDataProvider based on the database metadata
* Create a {@link CallMetaDataProvider} based on the database metadata
* @param dataSource used to retrieve metadata
* @param context the class that holds configuration and metadata
* @return instance of the CallMetaDataProvider implementation to be used
*/
static public CallMetaDataProvider createMetaDataProvider(DataSource dataSource, final CallMetaDataContext context) {
public static CallMetaDataProvider createMetaDataProvider(DataSource dataSource, final CallMetaDataContext context) {
try {
return (CallMetaDataProvider) JdbcUtils.extractDatabaseMetaData(dataSource, new DatabaseMetaDataCallback() {
@Override
@@ -104,27 +104,28 @@ public class CallMetaDataProviderFactory {
if ("Oracle".equals(databaseProductName)) {
provider = new OracleCallMetaDataProvider(databaseMetaData);
}
else if ("DB2".equals(databaseProductName)) {
provider = new Db2CallMetaDataProvider((databaseMetaData));
else if ("PostgreSQL".equals(databaseProductName)) {
provider = new PostgresCallMetaDataProvider((databaseMetaData));
}
else if ("Apache Derby".equals(databaseProductName)) {
provider = new DerbyCallMetaDataProvider((databaseMetaData));
}
else if ("PostgreSQL".equals(databaseProductName)) {
provider = new PostgresCallMetaDataProvider((databaseMetaData));
}
else if ("Sybase".equals(databaseProductName)) {
provider = new SybaseCallMetaDataProvider((databaseMetaData));
}
else if ("Microsoft SQL Server".equals(databaseProductName)) {
provider = new SqlServerCallMetaDataProvider((databaseMetaData));
else if ("DB2".equals(databaseProductName)) {
provider = new Db2CallMetaDataProvider((databaseMetaData));
}
else if ("HDB".equals(databaseProductName)) {
provider = new HanaCallMetaDataProvider((databaseMetaData));
}
else if ("Microsoft SQL Server".equals(databaseProductName)) {
provider = new SqlServerCallMetaDataProvider((databaseMetaData));
}
else if ("Sybase".equals(databaseProductName)) {
provider = new SybaseCallMetaDataProvider((databaseMetaData));
}
else {
provider = new GenericCallMetaDataProvider(databaseMetaData);
}
if (logger.isDebugEnabled()) {
logger.debug("Using " + provider.getClass().getName());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,26 +39,26 @@ public class Db2CallMetaDataProvider extends GenericCallMetaDataProvider {
try {
setSupportsCatalogsInProcedureCalls(databaseMetaData.supportsCatalogsInProcedureCalls());
}
catch (SQLException se) {
logger.debug("Error retrieving 'DatabaseMetaData.supportsCatalogsInProcedureCalls' - " + se.getMessage());
catch (SQLException ex) {
logger.debug("Error retrieving 'DatabaseMetaData.supportsCatalogsInProcedureCalls' - " + ex.getMessage());
}
try {
setSupportsSchemasInProcedureCalls(databaseMetaData.supportsSchemasInProcedureCalls());
}
catch (SQLException se) {
logger.debug("Error retrieving 'DatabaseMetaData.supportsSchemasInProcedureCalls' - " + se.getMessage());
catch (SQLException ex) {
logger.debug("Error retrieving 'DatabaseMetaData.supportsSchemasInProcedureCalls' - " + ex.getMessage());
}
try {
setStoresUpperCaseIdentifiers(databaseMetaData.storesUpperCaseIdentifiers());
}
catch (SQLException se) {
logger.debug("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + se.getMessage());
catch (SQLException ex) {
logger.debug("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + ex.getMessage());
}
try {
setStoresLowerCaseIdentifiers(databaseMetaData.storesLowerCaseIdentifiers());
}
catch (SQLException se) {
logger.debug("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + se.getMessage());
catch (SQLException ex) {
logger.debug("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + ex.getMessage());
}
}
@@ -67,6 +67,7 @@ public class Db2CallMetaDataProvider extends GenericCallMetaDataProvider {
if (schemaName != null) {
return super.metaDataSchemaNameToUse(schemaName);
}
// Use current user schema if no schema specified...
String userName = getUserName();
return (userName != null ? userName.toUpperCase() : null);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,11 +33,13 @@ public class DerbyCallMetaDataProvider extends GenericCallMetaDataProvider {
super(databaseMetaData);
}
@Override
public String metaDataSchemaNameToUse(String schemaName) {
if (schemaName != null) {
return super.metaDataSchemaNameToUse(schemaName);
}
// Use current user schema if no schema specified...
String userName = getUserName();
return (userName != null ? userName.toUpperCase() : null);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +20,8 @@ import java.sql.DatabaseMetaData;
import java.sql.SQLException;
/**
* The Derby specific implementation of the {@link org.springframework.jdbc.core.metadata.TableMetaDataProvider}.
* Overrides the Derby metadata info regarding retrieving generated keys. It seems to work OK so not sure why
* they claim it's not supported.
* The Derby specific implementation of {@link TableMetaDataProvider}.
* Overrides the Derby metadata info regarding retrieving generated keys.
*
* @author Thomas Risberg
* @since 3.0
@@ -53,4 +52,5 @@ public class DerbyTableMetaDataProvider extends GenericTableMetaDataProvider {
public boolean isGetGeneratedKeysSupported() {
return (super.isGetGeneratedKeysSupported() || this.supportsGeneratedKeysOverride);
}
}
@@ -33,7 +33,7 @@ import org.springframework.jdbc.core.SqlParameter;
import org.springframework.util.StringUtils;
/**
* Generic implementation for the {@link CallMetaDataProvider} interface.
* A generic implementation of the {@link CallMetaDataProvider} interface.
* This class can be extended to provide database specific behavior.
*
* @author Thomas Risberg
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,8 +34,8 @@ import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;
/**
* A generic implementation of the {@link TableMetaDataProvider} that should provide
* enough features for all supported databases.
* A generic implementation of the {@link TableMetaDataProvider} interface
* which should provide enough features for all supported databases.
*
* @author Thomas Risberg
* @author Juergen Hoeller
@@ -221,7 +221,6 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers': " + ex.getMessage());
}
}
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ public class HanaCallMetaDataProvider extends GenericCallMetaDataProvider {
super(databaseMetaData);
}
@Override
public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException {
super.initializeWithMetaData(databaseMetaData);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ public class HsqlTableMetaDataProvider extends GenericTableMetaDataProvider {
super(databaseMetaData);
}
@Override
public boolean isGetGeneratedKeysSimulated() {
return true;
@@ -42,7 +42,7 @@ public class TableMetaDataProviderFactory {
/**
* Create a TableMetaDataProvider based on the database metadata.
* Create a {@link TableMetaDataProvider} based on the database metadata.
* @param dataSource used to retrieve metadata
* @param context the class that holds configuration and metadata
* @return instance of the TableMetaDataProvider implementation to be used
@@ -52,7 +52,7 @@ public class TableMetaDataProviderFactory {
}
/**
* Create a TableMetaDataProvider based on the database metadata.
* Create a {@link TableMetaDataProvider} based on the database metadata.
* @param dataSource used to retrieve metadata
* @param context the class that holds configuration and metadata
* @param nativeJdbcExtractor the NativeJdbcExtractor to be used
@@ -68,13 +68,11 @@ public class TableMetaDataProviderFactory {
String databaseProductName =
JdbcUtils.commonDatabaseName(databaseMetaData.getDatabaseProductName());
boolean accessTableColumnMetaData = context.isAccessTableColumnMetaData();
TableMetaDataProvider provider;
if ("Oracle".equals(databaseProductName)) {
provider = new OracleTableMetaDataProvider(databaseMetaData,
context.isOverrideIncludeSynonymsDefault());
}
else if ("HSQL Database Engine".equals(databaseProductName)) {
provider = new HsqlTableMetaDataProvider(databaseMetaData);
provider = new OracleTableMetaDataProvider(
databaseMetaData, context.isOverrideIncludeSynonymsDefault());
}
else if ("PostgreSQL".equals(databaseProductName)) {
provider = new PostgresTableMetaDataProvider(databaseMetaData);
@@ -82,12 +80,16 @@ public class TableMetaDataProviderFactory {
else if ("Apache Derby".equals(databaseProductName)) {
provider = new DerbyTableMetaDataProvider(databaseMetaData);
}
else if ("HSQL Database Engine".equals(databaseProductName)) {
provider = new HsqlTableMetaDataProvider(databaseMetaData);
}
else {
provider = new GenericTableMetaDataProvider(databaseMetaData);
}
if (nativeJdbcExtractor != null) {
provider.setNativeJdbcExtractor(nativeJdbcExtractor);
}
if (logger.isDebugEnabled()) {
logger.debug("Using " + provider.getClass().getSimpleName());
}
@@ -24,7 +24,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Base class for {@link EmbeddedDatabaseConfigurer} implementations providing common shutdown behavior.
* Base class for {@link EmbeddedDatabaseConfigurer} implementations
* providing common shutdown behavior through a "SHUTDOWN" statement.
*
* @author Oliver Gierke
* @author Juergen Hoeller
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.derby.jdbc.EmbeddedDriver;
/**
* {@link EmbeddedDatabaseConfigurer} for the Apache Derby database 10.6+.
* {@link EmbeddedDatabaseConfigurer} for the Apache Derby database.
*
* <p>Call {@link #getInstance()} to get the singleton instance of this class.
*
* @author Oliver Gierke
@@ -40,10 +41,9 @@ final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigure
/**
* Get the singleton {@link DerbyEmbeddedDatabaseConfigurer} instance.
* @return the configurer
* @throws ClassNotFoundException if Derby is not on the classpath
* @return the configurer instance
*/
public static synchronized DerbyEmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException {
public static synchronized DerbyEmbeddedDatabaseConfigurer getInstance() {
if (instance == null) {
// disable log file
System.setProperty("derby.stream.error.method",
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,8 +30,7 @@ import javax.sql.DataSource;
public interface EmbeddedDatabaseConfigurer {
/**
* Configure the properties required to create and connect to the embedded
* database instance.
* Configure the properties required to create and connect to the embedded database.
* @param properties connection properties to configure
* @param databaseName the name of the embedded database
*/
@@ -39,7 +38,7 @@ public interface EmbeddedDatabaseConfigurer {
/**
* Shut down the embedded database instance that backs the supplied {@link DataSource}.
* @param dataSource the data source
* @param dataSource the corresponding {@link DataSource}
* @param databaseName the name of the database being shut down
*/
void shutdown(DataSource dataSource, String databaseName);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@ package org.springframework.jdbc.datasource.embedded;
import org.springframework.util.Assert;
/**
* Maps well-known {@linkplain EmbeddedDatabaseType embedded database types} to
* {@link EmbeddedDatabaseConfigurer} strategies.
* Maps well-known {@linkplain EmbeddedDatabaseType embedded database types}
* to {@link EmbeddedDatabaseConfigurer} strategies.
*
* @author Keith Donald
* @author Oliver Gierke
@@ -29,6 +29,12 @@ import org.springframework.util.Assert;
*/
final class EmbeddedDatabaseConfigurerFactory {
/**
* Return a configurer instance for the given embedded database type.
* @param type HSQL, H2 or Derby
* @return the configurer instance
* @throws IllegalStateException if the driver for the specified database type is not available
*/
public static EmbeddedDatabaseConfigurer getConfigurer(EmbeddedDatabaseType type) throws IllegalStateException {
Assert.notNull(type, "EmbeddedDatabaseType is required");
try {
@@ -44,13 +50,11 @@ final class EmbeddedDatabaseConfigurerFactory {
}
}
catch (ClassNotFoundException ex) {
throw new IllegalStateException("Driver for test database type [" + type +
"] is not available in the classpath", ex);
throw new IllegalStateException("Driver for test database type [" + type + "] is not available", ex);
}
catch (NoClassDefFoundError err) {
throw new IllegalStateException("Driver for test database type [" + type + "] is not available", err);
}
}
private EmbeddedDatabaseConfigurerFactory() {
/* no-op */
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.springframework.util.ClassUtils;
/**
* {@link EmbeddedDatabaseConfigurer} for an H2 embedded database instance.
*
* <p>Call {@link #getInstance()} to get the singleton instance of this class.
*
* @author Oliver Gierke
@@ -38,7 +39,7 @@ final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigu
/**
* Get the singleton {@code H2EmbeddedDatabaseConfigurer} instance.
* @return the configurer
* @return the configurer instance
* @throws ClassNotFoundException if H2 is not on the classpath
*/
@SuppressWarnings("unchecked")
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.springframework.util.ClassUtils;
/**
* {@link EmbeddedDatabaseConfigurer} for an HSQL embedded database instance.
*
* <p>Call {@link #getInstance()} to get the singleton instance of this class.
*
* @author Keith Donald
@@ -37,7 +38,7 @@ final class HsqlEmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfi
/**
* Get the singleton {@link HsqlEmbeddedDatabaseConfigurer} instance.
* @return the configurer
* @return the configurer instance
* @throws ClassNotFoundException if HSQL is not on the classpath
*/
@SuppressWarnings("unchecked")
@@ -17,7 +17,6 @@
package org.springframework.jdbc.support;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Blob;
import java.sql.Clob;
@@ -420,9 +419,10 @@ public abstract class JdbcUtils {
}
/**
* Extract a common name for the database in use even if various drivers/platforms provide varying names.
* Extract a common name for the target database in use even if
* various drivers/platforms provide varying names at runtime.
* @param source the name as provided in database metadata
* @return the common name to be used
* @return the common name to be used (e.g. "DB2" or "Sybase")
*/
public static String commonDatabaseName(String source) {
String name = source;
@@ -444,10 +444,10 @@ public abstract class JdbcUtils {
* @return whether the type is numeric
*/
public static boolean isNumeric(int sqlType) {
return Types.BIT == sqlType || Types.BIGINT == sqlType || Types.DECIMAL == sqlType ||
return (Types.BIT == sqlType || Types.BIGINT == sqlType || Types.DECIMAL == sqlType ||
Types.DOUBLE == sqlType || Types.FLOAT == sqlType || Types.INTEGER == sqlType ||
Types.NUMERIC == sqlType || Types.REAL == sqlType || Types.SMALLINT == sqlType ||
Types.TINYINT == sqlType;
Types.TINYINT == sqlType);
}
/**
@@ -19,13 +19,16 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given sequence
* on DB2/390 or DB2/400. Thanks to Jens Eickmeyer for the suggestion!
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given sequence on DB2 for the mainframe (z/OS, DB2/390, DB2/400).
*
* <p>Thanks to Jens Eickmeyer for the suggestion!
*
* @author Juergen Hoeller
* @since 2.5.3
* @see DB2SequenceMaxValueIncrementer
* @deprecated in favor of the differently named {@link Db2MainframeMaxValueIncrementer}
*/
@Deprecated
public class DB2MainframeSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
/**
@@ -19,14 +19,17 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given sequence
* on DB2 UDB (for Unix and Windows). Thanks to Mark MacMahon for the suggestion!
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given sequence on DB2 LUW (for Linux, Unix and Windows).
*
* <p>Thanks to Mark MacMahon for the suggestion!
*
* @author Juergen Hoeller
* @since 1.1.3
* @see DB2MainframeSequenceMaxValueIncrementer
* @deprecated in favor of the specifically named {@link Db2LuwMaxValueIncrementer}
*/
public class DB2SequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
@Deprecated
public class DB2SequenceMaxValueIncrementer extends Db2LuwMaxValueIncrementer {
/**
* Default constructor for bean property style usage.
@@ -45,10 +48,4 @@ public class DB2SequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncr
super(dataSource, incrementerName);
}
@Override
protected String getSequenceQuery() {
return "values nextval for " + getIncrementerName();
}
}
@@ -0,0 +1,56 @@
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given sequence on DB2 LUW (for Linux, Unix and Windows).
*
* <p>Thanks to Mark MacMahon for the suggestion!
*
* @author Juergen Hoeller
* @since 4.3.15
* @see Db2MainframeMaxValueIncrementer
*/
public class Db2LuwMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
/**
* Default constructor for bean property style usage.
* @see #setDataSource
* @see #setIncrementerName
*/
public Db2LuwMaxValueIncrementer() {
}
/**
* Convenience constructor.
* @param dataSource the DataSource to use
* @param incrementerName the name of the sequence/table to use
*/
public Db2LuwMaxValueIncrementer(DataSource dataSource, String incrementerName) {
super(dataSource, incrementerName);
}
@Override
protected String getSequenceQuery() {
return "values nextval for " + getIncrementerName();
}
}
@@ -0,0 +1,56 @@
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given sequence on DB2 for the mainframe (z/OS, DB2/390, DB2/400).
*
* <p>Thanks to Jens Eickmeyer for the suggestion!
*
* @author Juergen Hoeller
* @since 4.3.15
* @see Db2LuwMaxValueIncrementer
*/
public class Db2MainframeMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
/**
* Default constructor for bean property style usage.
* @see #setDataSource
* @see #setIncrementerName
*/
public Db2MainframeMaxValueIncrementer() {
}
/**
* Convenience constructor.
* @param dataSource the DataSource to use
* @param incrementerName the name of the sequence/table to use
*/
public Db2MainframeMaxValueIncrementer(DataSource dataSource, String incrementerName) {
super(dataSource, incrementerName);
}
@Override
protected String getSequenceQuery() {
return "select next value for " + getIncrementerName() + " from sysibm.sysdummy1";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,8 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given H2 Database sequence.
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given H2 sequence.
*
* @author Thomas Risberg
* @since 2.5
@@ -0,0 +1,54 @@
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given SAP HANA sequence.
*
* @author Jonathan Bregler
* @author Juergen Hoeller
* @since 4.3.15
*/
public class HanaSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
/**
* Default constructor for bean property style usage.
* @see #setDataSource
* @see #setIncrementerName
*/
public HanaSequenceMaxValueIncrementer() {
}
/**
* Convenience constructor.
* @param dataSource the DataSource to use
* @param incrementerName the name of the sequence/table to use
*/
public HanaSequenceMaxValueIncrementer(DataSource dataSource, String incrementerName) {
super(dataSource, incrementerName);
}
@Override
protected String getSequenceQuery() {
return "select " + getIncrementerName() + ".nextval from dummy";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +19,13 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given HSQL sequence.
* Thanks to Guillaume Bilodeau for the suggestion!
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given HSQL sequence.
*
* <p><b>NOTE:</b> This is an alternative to using a regular table to support generating
* unique keys that was necessary in previous versions of HSQL.
* <p>Thanks to Guillaume Bilodeau for the suggestion!
*
* <p><b>NOTE:</b> This is an alternative to using a regular table to support
* generating unique keys that was necessary in previous versions of HSQL.
*
* @author Thomas Risberg
* @since 2.5
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,8 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given Oracle sequence.
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given Oracle sequence.
*
* @author Dmitriy Kopylenko
* @author Thomas Risberg
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,12 +19,16 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given PostgreSQL sequence.
* Thanks to Tomislav Urban for the suggestion!
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given PostgreSQL sequence.
*
* <p>Thanks to Tomislav Urban for the suggestion!
*
* @author Juergen Hoeller
* @deprecated in favor of the differently named {@link PostgresSequenceMaxValueIncrementer}
*/
public class PostgreSQLSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
@Deprecated
public class PostgreSQLSequenceMaxValueIncrementer extends PostgresSequenceMaxValueIncrementer {
/**
* Default constructor for bean property style usage.
@@ -43,10 +47,4 @@ public class PostgreSQLSequenceMaxValueIncrementer extends AbstractSequenceMaxVa
super(dataSource, incrementerName);
}
@Override
protected String getSequenceQuery() {
return "select nextval('" + getIncrementerName() + "')";
}
}
@@ -0,0 +1,55 @@
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given PostgreSQL sequence.
*
* <p>Thanks to Tomislav Urban for the suggestion!
*
* @author Juergen Hoeller
* @since 4.3.15
*/
public class PostgresSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
/**
* Default constructor for bean property style usage.
* @see #setDataSource
* @see #setIncrementerName
*/
public PostgresSequenceMaxValueIncrementer() {
}
/**
* Convenience constructor.
* @param dataSource the DataSource to use
* @param incrementerName the name of the sequence/table to use
*/
public PostgresSequenceMaxValueIncrementer(DataSource dataSource, String incrementerName) {
super(dataSource, incrementerName);
}
@Override
protected String getSequenceQuery() {
return "select nextval('" + getIncrementerName() + "')";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,7 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that increments
* the maximum value of a given Sybase SQL Anywhere table
* {@link DataFieldMaxValueIncrementer} that increments the maximum value of a given Sybase table
* with the equivalent of an auto-increment column. Note: If you use this class, your table key
* column should <i>NOT</i> be defined as an IDENTITY column, as the sequence table does the job.
*
@@ -40,9 +39,9 @@ import javax.sql.DataSource;
* is rolled back, the unused values will never be served. The maximum hole size in
* numbering is consequently the value of cacheSize.
*
* <b>HINT:</b> Since Sybase Anywhere supports the JDBC 3.0 {@code getGeneratedKeys} method,
* it is recommended to use IDENTITY columns directly in the tables and then using a
* {@link org.springframework.jdbc.core.simple.SimpleJdbcInsert} or utilizing
* <b>HINT:</b> Since Sybase Anywhere supports the JDBC 3.0 {@code getGeneratedKeys}
* method, it is recommended to use IDENTITY columns directly in the tables and then
* using a {@link org.springframework.jdbc.core.simple.SimpleJdbcInsert} or utilizing
* a {@link org.springframework.jdbc.support.KeyHolder} when calling the with the
* {@code update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder)}
* method of the {@link org.springframework.jdbc.core.JdbcTemplate}.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,9 +39,9 @@ import javax.sql.DataSource;
* is rolled back, the unused values will never be served. The maximum hole size in
* numbering is consequently the value of cacheSize.
*
* <b>HINT:</b> Since Sybase supports the JDBC 3.0 {@code getGeneratedKeys} method,
* it is recommended to use IDENTITY columns directly in the tables and then using a
* {@link org.springframework.jdbc.core.simple.SimpleJdbcInsert} or utilizing
* <b>HINT:</b> Since Sybase Adaptive Server supports the JDBC 3.0 {@code getGeneratedKeys}
* method, it is recommended to use IDENTITY columns directly in the tables and then
* using a {@link org.springframework.jdbc.core.simple.SimpleJdbcInsert} or utilizing
* a {@link org.springframework.jdbc.support.KeyHolder} when calling the with the
* {@code update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder)}
* method of the {@link org.springframework.jdbc.core.JdbcTemplate}.