This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch past-M2 in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit e5c0ca6de75ceaf567ae5c85a01ad551b3541f8f Author: Andrus Adamchik <[email protected]> AuthorDate: Sun May 31 10:31:28 2026 -0400 Unwinding confusing adapter hierarchy: SQLServer no longer inherits from Sybase --- .../cayenne/dba/sqlserver/SQLServerAdapter.java | 249 +++++++++++++-------- .../SQLServerEJBQLConditionTranslator.java | 50 +++++ .../SQLServerEJBQLSubselectTranslator.java | 45 ++++ .../sqlserver/SQLServerEJBQLTranslatorFactory.java | 31 +++ .../cayenne/unit/dba/SQLServerTestDbAdapter.java | 58 +++-- .../test/resources/ddl/sqlserver/create-out-sp.sql | 22 ++ .../resources/ddl/sqlserver/create-select-sp.sql | 31 +++ .../resources/ddl/sqlserver/create-update-sp.sql | 25 +++ .../resources/ddl/sqlserver/create-update-sp2.sql | 24 ++ .../test/resources/ddl/sqlserver/drop-out-sp.sql | 22 ++ .../resources/ddl/sqlserver/drop-select-sp.sql | 22 ++ .../resources/ddl/sqlserver/drop-update-sp.sql | 22 ++ .../resources/ddl/sqlserver/drop-update-sp2.sql | 22 ++ 13 files changed, 517 insertions(+), 106 deletions(-) diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java index a06dbf053..876176049 100644 --- a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java +++ b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java @@ -19,23 +19,25 @@ package org.apache.cayenne.dba.sqlserver; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - import org.apache.cayenne.CayenneRuntimeException; import org.apache.cayenne.access.DataNode; import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor; +import org.apache.cayenne.access.translator.ParameterBinding; +import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory; +import org.apache.cayenne.access.types.ByteArrayType; +import org.apache.cayenne.access.types.ByteType; import org.apache.cayenne.access.types.CharType; import org.apache.cayenne.access.types.ExtendedType; import org.apache.cayenne.access.types.ExtendedTypeFactory; import org.apache.cayenne.access.types.ExtendedTypeMap; import org.apache.cayenne.access.types.JsonType; +import org.apache.cayenne.access.types.ShortType; import org.apache.cayenne.access.types.ValueObjectTypeRegistry; import org.apache.cayenne.configuration.Constants; import org.apache.cayenne.configuration.RuntimeProperties; -import org.apache.cayenne.dba.sybase.SybaseAdapter; +import org.apache.cayenne.dba.DefaultQuotingStrategy; +import org.apache.cayenne.dba.JdbcAdapter; +import org.apache.cayenne.dba.QuotingStrategy; import org.apache.cayenne.di.Inject; import org.apache.cayenne.map.DbAttribute; import org.apache.cayenne.map.DbEntity; @@ -43,6 +45,12 @@ import org.apache.cayenne.query.Query; import org.apache.cayenne.query.SQLAction; import org.apache.cayenne.resource.ResourceLocator; +import java.sql.PreparedStatement; +import java.sql.Types; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + /** * <p> * Cayenne DbAdapter implementation for <a @@ -80,94 +88,154 @@ import org.apache.cayenne.resource.ResourceLocator; * * @since 1.1 */ -public class SQLServerAdapter extends SybaseAdapter { - - /** - * Stores the major version of the database. - * Database versions 12 and higher supports the use of LIMIT,lower versions use TOP N. - * - * @since 4.2 - */ - private Integer version; - - private final List<String> SYSTEM_SCHEMAS = List.of( - "db_accessadmin", "db_backupoperator", - "db_datareader", "db_datawriter", "db_ddladmin", "db_denydatareader", - "db_denydatawriter", "sys", "db_owner", "db_securityadmin", "INFORMATION_SCHEMA" - ); - - private final List<String> SYSTEM_CATALOGS = List.of("model", "msdb", "tempdb"); - - public SQLServerAdapter(@Inject RuntimeProperties runtimeProperties, - @Inject(Constants.DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes, - @Inject(Constants.USER_TYPES_LIST) List<ExtendedType> userExtendedTypes, - @Inject(Constants.TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories, - @Inject(Constants.RESOURCE_LOCATOR) ResourceLocator resourceLocator, - @Inject ValueObjectTypeRegistry valueObjectTypeRegistry) { - super(runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories, resourceLocator, valueObjectTypeRegistry); - - this.setSupportsBatchUpdates(true); - } +public class SQLServerAdapter extends JdbcAdapter { + + /** + * Stores the major version of the database. + * Database versions 12 and higher supports the use of LIMIT,lower versions use TOP N. + */ + private Integer version; + + private final List<String> SYSTEM_SCHEMAS = List.of( + "db_accessadmin", "db_backupoperator", + "db_datareader", "db_datawriter", "db_ddladmin", "db_denydatareader", + "db_denydatawriter", "sys", "db_owner", "db_securityadmin", "INFORMATION_SCHEMA" + ); + + private final List<String> SYSTEM_CATALOGS = List.of("model", "msdb", "tempdb"); + + public SQLServerAdapter(@Inject RuntimeProperties runtimeProperties, + @Inject(Constants.DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes, + @Inject(Constants.USER_TYPES_LIST) List<ExtendedType> userExtendedTypes, + @Inject(Constants.TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories, + @Inject(Constants.RESOURCE_LOCATOR) ResourceLocator resourceLocator, + @Inject ValueObjectTypeRegistry valueObjectTypeRegistry) { + super(runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories, resourceLocator, valueObjectTypeRegistry); + + this.setSupportsGeneratedKeys(true); + this.setSupportsBatchUpdates(true); + } + + @Override + protected QuotingStrategy createQuotingStrategy() { + return new DefaultQuotingStrategy("[", "]"); + } + + @Override + protected EJBQLTranslatorFactory createEJBQLTranslatorFactory() { + return new SQLServerEJBQLTranslatorFactory(); + } + + /** + * Returns the word "go". + */ + @Override + public String getBatchTerminator() { + return "go"; + } + + @Override + public void bindParameter(PreparedStatement statement, ParameterBinding binding) throws Exception { + + // SQL Server driver doesn't like CLOBs and BLOBs as parameters + if (binding.getValue() == null) { + if (binding.getJdbcType() == Types.CLOB) { + binding.setJdbcType(Types.VARCHAR); + } else if (binding.getJdbcType() == Types.BLOB) { + binding.setJdbcType(Types.VARBINARY); + } + } + + if (binding.getValue() == null && binding.getJdbcType() == 0) { + statement.setNull(binding.getStatementPosition(), Types.VARCHAR); + } else { + super.bindParameter(statement, binding); + } + } + + /** + * Overrides super implementation to correctly set up identity columns. + */ + @Override + public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) { + + super.createTableAppendColumn(sqlBuffer, column); + + if (column.isGenerated()) { + // current limitation - we don't allow to set identity parameters... + sqlBuffer.append(" IDENTITY (1, 1)"); + } + } /** * Not supported, see: <a href="https://github.com/microsoft/mssql-jdbc/issues/245">mssql-jdbc #245</a> */ - @Override - public boolean supportsGeneratedKeysForBatchInserts() { - return false; - } - - /** - * @since 4.2 - */ - @Override - public SQLTreeProcessor getSqlTreeProcessor() { - if(getVersion() != null && getVersion() >= 12) { - return new SQLServerTreeProcessorV12(); - } - return new SQLServerTreeProcessor(); - } - - @Override - protected void configureExtendedTypes(ExtendedTypeMap map) { - super.configureExtendedTypes(map); - - CharType charType = new CharType(true, false); - map.registerType(charType); - map.registerType(new JsonType(charType, true)); - } - - /** - * Uses SQLServerActionBuilder to create the right action. - * - * @since 1.2 - */ - @Override - public SQLAction getAction(Query query, DataNode node) { - return query.createSQLAction(new SQLServerActionBuilder(node, getVersion())); - } - - @Override - public List<String> getSystemSchemas() { - return SYSTEM_SCHEMAS; - } - - @Override - public List<String> getSystemCatalogs() { - return SYSTEM_CATALOGS; - } - - public Integer getVersion() { - return version; - } - - /** - * @since 4.2 - * @param version of the server as provided by the JDBC driver - */ - public void setVersion(Integer version) { - this.version = version; - } + @Override + public boolean supportsGeneratedKeysForBatchInserts() { + return false; + } + + /** + * @since 4.2 + */ + @Override + public SQLTreeProcessor getSqlTreeProcessor() { + if (getVersion() != null && getVersion() >= 12) { + return new SQLServerTreeProcessorV12(); + } + return new SQLServerTreeProcessor(); + } + + @Override + protected void configureExtendedTypes(ExtendedTypeMap map) { + super.configureExtendedTypes(map); + + // create specially configured CharType handler + map.registerType(new CharType(true, false)); + + // create specially configured ByteArrayType handler + map.registerType(new ByteArrayType(true, false)); + + // address driver inability to handle java.lang.Short and java.lang.Byte + map.registerType(new ShortType(true)); + map.registerType(new ByteType(true)); + + CharType charType = new CharType(true, false); + map.registerType(charType); + map.registerType(new JsonType(charType, true)); + } + + /** + * Uses SQLServerActionBuilder to create the right action. + * + * @since 1.2 + */ + @Override + public SQLAction getAction(Query query, DataNode node) { + return query.createSQLAction(new SQLServerActionBuilder(node, getVersion())); + } + + @Override + public List<String> getSystemSchemas() { + return SYSTEM_SCHEMAS; + } + + @Override + public List<String> getSystemCatalogs() { + return SYSTEM_CATALOGS; + } + + public Integer getVersion() { + return version; + } + + /** + * @param version of the server as provided by the JDBC driver + * @since 4.2 + */ + public void setVersion(Integer version) { + this.version = version; + } /** * Generates DDL to create unique index that allows multiple NULL values to comply with ANSI SQL, @@ -185,7 +253,6 @@ public class SQLServerAdapter extends SybaseAdapter { * @param source entity for the index * @param columns source columns for the index * @return DDL to create unique index - * * @since 4.2.1 */ @Override diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java new file mode 100644 index 000000000..49cc468ef --- /dev/null +++ b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java @@ -0,0 +1,50 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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.apache.cayenne.dba.sqlserver; + +import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator; +import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext; +import org.apache.cayenne.ejbql.EJBQLExpression; + +class SQLServerEJBQLConditionTranslator extends EJBQLConditionTranslator { + + boolean isExists; + + public SQLServerEJBQLConditionTranslator(EJBQLTranslationContext context) { + super(context); + } + + @Override + public boolean visitSubselect(EJBQLExpression expression) { + context.onSubselect(); + context.append(" ("); + expression.visit(new SQLServerEJBQLSubselectTranslator(context, isExists)); + context.append(')'); + isExists = false; + return false; + } + + @Override + public boolean visitExists(EJBQLExpression expression) { + isExists = true; + context.append(" EXISTS"); + return true; + } + +} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java new file mode 100644 index 000000000..a84a32c91 --- /dev/null +++ b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java @@ -0,0 +1,45 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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.apache.cayenne.dba.sqlserver; + +import org.apache.cayenne.access.translator.ejbql.EJBQLSelectTranslator; +import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext; +import org.apache.cayenne.ejbql.EJBQLExpression; + +class SQLServerEJBQLSubselectTranslator extends EJBQLSelectTranslator { + + boolean isExists; + + SQLServerEJBQLSubselectTranslator(EJBQLTranslationContext context, boolean isExists) { + super(context); + this.isExists = isExists; + } + + @Override + public boolean visitSelectExpressions(EJBQLExpression expression) { + if (isExists) { + context.append(" * "); + isExists = false; + } + else { + super.visitSelectExpressions(expression); + } + return false; + } +} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslatorFactory.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslatorFactory.java new file mode 100644 index 000000000..b56112a7e --- /dev/null +++ b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslatorFactory.java @@ -0,0 +1,31 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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.apache.cayenne.dba.sqlserver; + +import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext; +import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory; +import org.apache.cayenne.ejbql.EJBQLExpressionVisitor; + +class SQLServerEJBQLTranslatorFactory extends JdbcEJBQLTranslatorFactory { + + @Override + public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) { + return new SQLServerEJBQLConditionTranslator(context); + } +} diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/dba/SQLServerTestDbAdapter.java b/cayenne/src/test/java/org/apache/cayenne/unit/dba/SQLServerTestDbAdapter.java index af59a5da9..e0412a39c 100644 --- a/cayenne/src/test/java/org/apache/cayenne/unit/dba/SQLServerTestDbAdapter.java +++ b/cayenne/src/test/java/org/apache/cayenne/unit/dba/SQLServerTestDbAdapter.java @@ -21,16 +21,48 @@ package org.apache.cayenne.unit.dba; import org.apache.cayenne.dba.DbAdapter; import org.apache.cayenne.map.DataMap; +import org.apache.cayenne.map.Procedure; import java.sql.Connection; import java.util.Collection; -public class SQLServerTestDbAdapter extends SybaseTestDbAdapter { +public class SQLServerTestDbAdapter extends TestDbAdapter { public SQLServerTestDbAdapter(DbAdapter adapter) { super(adapter); } + @Override + public String getIdentifiersStartQuote() { + return "["; + } + + @Override + public String getIdentifiersEndQuote() { + return "]"; + } + + @Override + public boolean supportsStoredProcedures() { + return true; + } + + @Override + public void createdTables(Connection con, DataMap map) throws Exception { + Procedure proc = map.getProcedure("cayenne_tst_select_proc"); + if (proc != null && proc.getDataMap() == map) { + executeDDL(con, "sqlserver", "create-select-sp.sql"); + executeDDL(con, "sqlserver", "create-update-sp.sql"); + executeDDL(con, "sqlserver", "create-update-sp2.sql"); + executeDDL(con, "sqlserver", "create-out-sp.sql"); + } + } + + @Override + public boolean supportsLobs() { + return true; + } + @Override public boolean handlesNullVsEmptyLOBs() { return true; @@ -46,6 +78,16 @@ public class SQLServerTestDbAdapter extends SybaseTestDbAdapter { dropProcedures(conn, map); } + protected void dropProcedures(Connection con, DataMap map) throws Exception { + Procedure proc = map.getProcedure("cayenne_tst_select_proc"); + if (proc != null && proc.getDataMap() == map) { + executeDDL(con, "sqlserver", "drop-select-sp.sql"); + executeDDL(con, "sqlserver", "drop-update-sp.sql"); + executeDDL(con, "sqlserver", "drop-update-sp2.sql"); + executeDDL(con, "sqlserver", "drop-out-sp.sql"); + } + } + @Override public boolean supportsLobComparisons() { // people are suggesting using LIKE to compare TEXT columns... not sure @@ -65,20 +107,6 @@ public class SQLServerTestDbAdapter extends SybaseTestDbAdapter { return true; } - // The code below was used with SQLServer <= 2005 to turn of autogenerated - // keys. - // Modern SQLServer driver supports autogen keys just fine. - - // public void unchecked(CayenneTestResources resources) { - // // see if MSSQL driver is used and turn off identity columns in this - // case... - // - // String driver = resources.getConnectionInfo().getJdbcDriver(); - // if (driver != null && driver.startsWith("com.microsoft.") ) { - // ((JdbcAdapter) getAdapter()).setSupportsGeneratedKeys(false); - // } - // } - @Override public boolean supportsExpressionInHaving() { return false; diff --git a/cayenne/src/test/resources/ddl/sqlserver/create-out-sp.sql b/cayenne/src/test/resources/ddl/sqlserver/create-out-sp.sql new file mode 100644 index 000000000..c30f3acb8 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/create-out-sp.sql @@ -0,0 +1,22 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +CREATE PROCEDURE cayenne_tst_out_proc @in_param INT, @out_param INT output AS +BEGIN + SELECT @out_param = @in_param * 2 +END \ No newline at end of file diff --git a/cayenne/src/test/resources/ddl/sqlserver/create-select-sp.sql b/cayenne/src/test/resources/ddl/sqlserver/create-select-sp.sql new file mode 100644 index 000000000..1bc982b02 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/create-select-sp.sql @@ -0,0 +1,31 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +CREATE PROCEDURE cayenne_tst_select_proc @aName VARCHAR(255), @paintingPrice INT AS +BEGIN + BEGIN TRANSACTION + UPDATE PAINTING SET ESTIMATED_PRICE = ESTIMATED_PRICE * 2 + WHERE ESTIMATED_PRICE < @paintingPrice + COMMIT + + SELECT DISTINCT A.ARTIST_ID, A.ARTIST_NAME, A.DATE_OF_BIRTH + FROM ARTIST A, PAINTING P + WHERE A.ARTIST_ID = P.ARTIST_ID AND + A.ARTIST_NAME = @aName + ORDER BY A.ARTIST_ID +END \ No newline at end of file diff --git a/cayenne/src/test/resources/ddl/sqlserver/create-update-sp.sql b/cayenne/src/test/resources/ddl/sqlserver/create-update-sp.sql new file mode 100644 index 000000000..c2870a094 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/create-update-sp.sql @@ -0,0 +1,25 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +CREATE PROCEDURE cayenne_tst_upd_proc @paintingPrice INT AS +BEGIN + BEGIN TRANSACTION UPDATE + PAINTING SET ESTIMATED_PRICE = ESTIMATED_PRICE * 2 + WHERE ESTIMATED_PRICE < @paintingPrice + COMMIT +END diff --git a/cayenne/src/test/resources/ddl/sqlserver/create-update-sp2.sql b/cayenne/src/test/resources/ddl/sqlserver/create-update-sp2.sql new file mode 100644 index 000000000..5d5010ff4 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/create-update-sp2.sql @@ -0,0 +1,24 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +CREATE PROCEDURE cayenne_tst_upd_proc2 AS +BEGIN + BEGIN TRANSACTION UPDATE + PAINTING SET ESTIMATED_PRICE = ESTIMATED_PRICE * 2 + COMMIT +END diff --git a/cayenne/src/test/resources/ddl/sqlserver/drop-out-sp.sql b/cayenne/src/test/resources/ddl/sqlserver/drop-out-sp.sql new file mode 100644 index 000000000..12e23fa8d --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/drop-out-sp.sql @@ -0,0 +1,22 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +if exists (SELECT * FROM sysobjects WHERE name = 'cayenne_tst_out_proc') +BEGIN + DROP PROCEDURE cayenne_tst_out_proc +END \ No newline at end of file diff --git a/cayenne/src/test/resources/ddl/sqlserver/drop-select-sp.sql b/cayenne/src/test/resources/ddl/sqlserver/drop-select-sp.sql new file mode 100644 index 000000000..a78418709 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/drop-select-sp.sql @@ -0,0 +1,22 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +if exists (SELECT * FROM sysobjects WHERE name = 'cayenne_tst_select_proc') +BEGIN + DROP PROCEDURE cayenne_tst_select_proc +END \ No newline at end of file diff --git a/cayenne/src/test/resources/ddl/sqlserver/drop-update-sp.sql b/cayenne/src/test/resources/ddl/sqlserver/drop-update-sp.sql new file mode 100644 index 000000000..00615ebd6 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/drop-update-sp.sql @@ -0,0 +1,22 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +if exists (SELECT * FROM sysobjects WHERE name = 'cayenne_tst_upd_proc') +BEGIN + DROP PROCEDURE cayenne_tst_upd_proc +END \ No newline at end of file diff --git a/cayenne/src/test/resources/ddl/sqlserver/drop-update-sp2.sql b/cayenne/src/test/resources/ddl/sqlserver/drop-update-sp2.sql new file mode 100644 index 000000000..436b1ab30 --- /dev/null +++ b/cayenne/src/test/resources/ddl/sqlserver/drop-update-sp2.sql @@ -0,0 +1,22 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + ****************************************************************/ +if exists (SELECT * FROM sysobjects WHERE name = 'cayenne_tst_upd_proc2') +BEGIN + DROP PROCEDURE cayenne_tst_upd_proc2 +END \ No newline at end of file
