You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2013/05/03 23:26:06 UTC
svn commit: r1478984 [2/3] - in
/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql:
conf/ outlets/ templates/ddl/ templates/ddl/derby/ templates/ddl/hsqldb/
templates/ddl/mssql/ templates/ddl/mysql/ templates/d...
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropForeignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropForeignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropForeignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropForeignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+return """\
+ALTER TABLE $foreignKey.parent.name
+ DROP CONSTRAINT $foreignKey.name;
+
+
+"""
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropTable.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropTable.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropTable.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropTable.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,51 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Table table = torqueGenGroovy.model
+int counter = torqueGenGroovy.counter;
+
+return """\
+IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '$table.unqualifiedName')
+BEGIN
+ DECLARE @reftable_${counter} nvarchar(60), @constraintname_${counter} nvarchar(60)
+ DECLARE refcursor CURSOR FOR
+ select reftables.name tablename, cons.name constraintname
+ from sysobjects tables,
+ sysobjects reftables,
+ sysobjects cons,
+ sysreferences ref
+ where tables.id = ref.rkeyid
+ and cons.id = ref.constid
+ and reftables.id = ref.fkeyid
+ and tables.name = '$table.name'
+ OPEN refcursor
+ FETCH NEXT from refcursor into @reftable_${counter}, @constraintname_${counter}
+ while @@FETCH_STATUS = 0
+ BEGIN
+ exec ('alter table '+@reftable_${counter}+' drop constraint '+@constraintname_${counter})
+ FETCH NEXT from refcursor into @reftable_${counter}, @constraintname_${counter}
+ END
+ CLOSE refcursor
+ DEALLOCATE refcursor
+ DROP TABLE $table.name
+END
+;
+"""
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropView.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropView.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropView.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/dropView.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,30 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+//
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.View
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+View view = torqueGenGroovy.model
+if (!view.skipSql.equals("true"))
+{
+ return """\
+DROP VIEW ${view.name};
+
+"""
+}
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/foreignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/foreignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/foreignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/foreignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,67 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+def result = """\
+BEGIN
+ALTER TABLE $foreignKey.parent.name
+ ADD CONSTRAINT $foreignKey.name
+ FOREIGN KEY ($foreignKey.localColumnNames)
+ REFERENCES $foreignKey.foreignTable ($foreignKey.foreignColumnNames)"""
+if (foreignKey.onUpdate == "setnull")
+{
+ result += """
+ ON UPDATE SET NULL"""
+}
+else if (foreignKey.onUpdate == "restrict")
+{
+ result += """
+ ON UPDATE NO ACTION"""
+}
+else if (foreignKey.onUpdate)
+{
+ result += """
+ ON UPDATE ${foreignKey.onUpdate.toUpperCase()}"""
+}
+if (foreignKey.onDelete == "setnull")
+{
+ result += """
+
+ ON DELETE SET NULL"""
+}
+else if (foreignKey.onDelete == "restrict")
+{
+ result += """
+ ON DELETE NO ACTION"""
+}
+else if (foreignKey.onDelete)
+{
+ result += """
+
+ ON DELETE ${foreignKey.onDelete.toUpperCase()}"""
+}
+result += """
+
+END
+;
+"""
+return result
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/index.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/index.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/index.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/index.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,39 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Index
+import org.apache.commons.lang.StringUtils
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Index index = torqueGenGroovy.model
+String indexName = index.name
+if (index.indexColumnNames != "")
+{
+ if (StringUtils.isBlank(indexName))
+ {
+ indexName = ""
+ }
+ else
+ {
+ indexName = " " + indexName
+ }
+ return """\
+CREATE INDEX${indexName} ON ${index.parent.name} ($index.indexColumnNames);
+"""
+}
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/primaryKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/primaryKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/primaryKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/primaryKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Table table = torqueGenGroovy.model
+if (table.primaryKeyColumnNames != "")
+{
+ return """\
+ CONSTRAINT ${table.primaryKeyConstraintName} PRIMARY KEY($table.primaryKeyColumnNames),
+"""
+}
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/sequence.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/sequence.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/sequence.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/sequence.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,19 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+//
+// No sequences in mysql
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,46 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Table table = torqueGenGroovy.model
+String cols = torqueGenGroovy.mergepoint("columns")
+String pk = torqueGenGroovy.mergepoint("primaryKey")
+String unique = torqueGenGroovy.mergepoint("unique")
+String index = torqueGenGroovy.mergepoint("index")
+String createTableSql = "${cols}${pk}${unique}"
+int lastCommaPos = createTableSql.lastIndexOf(",")
+if (lastCommaPos != -1)
+{
+ createTableSql = createTableSql.substring(0, lastCommaPos)
+}
+
+def result = """
+/* ----------------------------------------------------------------------- */
+/* $table.name */
+/* ----------------------------------------------------------------------- */
+CREATE TABLE $table.name
+(
+${createTableSql}
+)
+${torqueGenGroovy.mergepoint("createOptions")}
+;
+${index}
+"""
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableComment.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableComment.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableComment.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableComment.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,19 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+//
+// no Comments on tables in mysql
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableCreateOptions.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableCreateOptions.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableCreateOptions.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/tableCreateOptions.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,24 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+//
+//////////
+//
+// version $Id: tableCreateOptions.vm 1437184 2013-01-22 21:25:57Z tfischer $
+//
+// No table create options are implemented.
+//
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/unique.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/unique.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/unique.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/unique.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,26 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Unique
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Unique unique = torqueGenGroovy.model
+if (unique.uniqueColumnNames != "")
+{
+ return " CONSTRAINT ${unique.name} UNIQUE ($unique.uniqueColumnNames),"
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/view.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/view.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/view.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/view.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,47 @@
+package org.apache.torque.templates.sql.templates.ddl.mssql
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.View
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+View view = torqueGenGroovy.model
+if (!view.skipSql.equals("true"))
+{
+ if (view.createSql != null)
+ {
+ return view.createSql + """
+
+"""
+ }
+ else
+ {
+ String cols = torqueGenGroovy.mergepoint("columns")
+ int lastCommaPos = cols.lastIndexOf(",")
+ if (lastCommaPos != -1)
+ {
+ cols = cols.substring(0, lastCommaPos)
+ }
+
+ return """CREATE VIEW ${view.name} AS
+ SELECT
+${cols}
+ ${view.sqlSuffix};
+
+"""
+ }
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/columnComment.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/columnComment.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/columnComment.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/columnComment.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,18 @@
+// 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
+//
+// 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.
+//
+// no Comments on columns in mysql
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,28 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Database
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Database database = torqueGenGroovy.model
+return """\
+-- -----------------------------------------------------------------------
+-- ${torqueGenGroovy.getOption("torque.database")} SQL script for schema $database.name
+-- -----------------------------------------------------------------------
+
+
+"""
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,28 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+return """\
+ALTER TABLE $foreignKey.parent.name
+ DROP FOREIGN KEY $foreignKey.name;
+
+
+"""
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropTable.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropTable.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropTable.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropTable.groovy Fri May 3 21:25:27 2013
@@ -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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Table table = torqueGenGroovy.model
+
+return """\
+drop table if exists $table.name;
+"""
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropView.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropView.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropView.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropView.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,18 @@
+// 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
+//
+// 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.
+//
+// Drop view not necessary in MySQL
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/foreignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/foreignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/foreignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/foreignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,53 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+def result = """\
+ALTER TABLE $foreignKey.parent.name
+ ADD CONSTRAINT $foreignKey.name
+ FOREIGN KEY ($foreignKey.localColumnNames)
+ REFERENCES $foreignKey.foreignTable ($foreignKey.foreignColumnNames)"""
+if (foreignKey.onUpdate == "setnull")
+{
+ result += """
+ ON UPDATE SET NULL"""
+}
+else if (foreignKey.onUpdate)
+{
+ result += """
+ ON UPDATE ${foreignKey.onUpdate.toUpperCase()}"""
+}
+if (foreignKey.onDelete == "setnull")
+{
+ result += """
+
+ ON DELETE SET NULL"""
+}
+else if (foreignKey.onDelete)
+{
+ result += """
+
+ ON DELETE ${foreignKey.onDelete.toUpperCase()}"""
+}
+result += """;
+
+"""
+return result
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/index.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/index.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/index.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/index.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,38 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Index
+import org.apache.commons.lang.StringUtils
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Index index = torqueGenGroovy.model
+if (index.indexColumnNames != "")
+{
+ String indexName = index.name
+ if (StringUtils.isBlank(indexName))
+ {
+ indexName = ""
+ }
+ else
+ {
+ indexName = " " + indexName
+ }
+ return """\
+ INDEX${indexName}($index.indexColumnNames),
+"""
+}
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/primaryKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/primaryKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/primaryKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/primaryKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,28 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Table table = torqueGenGroovy.model
+if (table.primaryKeyColumnNames != "")
+{
+ return """\
+ PRIMARY KEY($table.primaryKeyColumnNames),
+"""
+}
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/sequence.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/sequence.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/sequence.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/sequence.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,18 @@
+// 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
+//
+// 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.
+//
+// No sequences in mssql
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,43 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Table table = torqueGenGroovy.model
+String cols = torqueGenGroovy.mergepoint("columns")
+String pk = torqueGenGroovy.mergepoint("primaryKey")
+String unique = torqueGenGroovy.mergepoint("unique")
+String index = torqueGenGroovy.mergepoint("index")
+String createTableSql = "${cols}${pk}${unique}${index}"
+int lastCommaPos = createTableSql.lastIndexOf(",")
+if (lastCommaPos != -1)
+{
+ createTableSql = createTableSql.substring(0, lastCommaPos)
+}
+
+def result = """
+# -----------------------------------------------------------------------
+# $table.name
+# -----------------------------------------------------------------------
+CREATE TABLE $table.name
+(
+${createTableSql}${torqueGenGroovy.mergepoint("createOptions")}
+);
+
+"""
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableComment.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableComment.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableComment.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableComment.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,18 @@
+// 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
+//
+// 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.
+//
+// no Comments on tables in mssql
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableCreateOptions.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableCreateOptions.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableCreateOptions.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/tableCreateOptions.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,54 @@
+// 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
+//
+// 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.
+//
+//////////
+//
+// version $Id: tableCreateOptions.vm 1437184 2013-01-22 21:25:57Z tfischer $
+//
+// Creates the options for table creation.
+//
+org.apache.torque.templates.model.Table table = torqueGen.model
+for (org.apache.torque.templates.model.Option option : table.optionList)
+{
+ if (option.key == "ENGINE"
+ || option.key == "AVG_ROW_LENGTH"
+ || option.key == "CHARACTER SET"
+ || option.key == "DEFAULT CHARACTER SET"
+ || option.key == "CHECKSUM"
+ || option.key == "COLLATE"
+ || option.key == "DEFAULT COLLATE"
+ || option.key == "CONNECTION"
+ || option.key == "DATA DIRECTORY"
+ || option.key == "DELAY_KEY_WRITE"
+ || option.key == "INDEX DIRECTORY"
+ || option.key == "INSERT_METHOD"
+ || option.key == "KEY_BLOCK_SIZE"
+ || option.key == "MAX_ROWS"
+ || option.key == "MIN_ROWS"
+ || option.key == "PACK_KEYS"
+ || option.key == "PASSWORD"
+ || option.key == "ROW_FORMAT"
+ || option.key == "TABLESPACE"
+ || option.key == "UNION")
+ {
+ return " $option.key=$option.value"
+ }
+ else if (option.key == "PARTITION BY")
+ {
+ return " $option.key $option.value"
+ }
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/unique.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/unique.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/unique.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/unique.groovy Fri May 3 21:25:27 2013
@@ -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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Unique
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Unique unique = torqueGenGroovy.model
+if (unique.uniqueColumnNames != "")
+{
+ return " UNIQUE ${unique.name} ($unique.uniqueColumnNames),"
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/view.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/view.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/view.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/view.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,46 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.View
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+View view = torqueGenGroovy.model
+if (!view.skipSql.equals("true"))
+{
+ if (view.createSql != null)
+ {
+ return view.createSql + """
+
+"""
+ }
+ else
+ {
+ String cols = torqueGenGroovy.mergepoint("columns")
+ int lastCommaPos = cols.lastIndexOf(",")
+ if (lastCommaPos != -1)
+ {
+ cols = cols.substring(0, lastCommaPos)
+ }
+
+ return """CREATE OR REPLACE VIEW ${view.name} AS
+ SELECT
+${cols}
+ ${view.sqlSuffix};
+
+"""
+ }
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/columnComment.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/columnComment.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/columnComment.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/columnComment.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+// 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
+//
+// 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.
+//
+// no Comments on columns in mysql
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Column
+import org.apache.commons.lang.StringUtils
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Column column = torqueGenGroovy.model
+if (StringUtils.isNotBlank(column.description))
+{
+ return """COMMENT ON COLUMN ${column.parent.name}.${column.name} IS '${column.description}';
+"""
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/databaseStart.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/databaseStart.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/databaseStart.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/databaseStart.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Database
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Database database = torqueGenGroovy.model
+return """\
+-- -----------------------------------------------------------------------
+-- ${torqueGenGroovy.getOption("torque.database")} SQL script for schema $database.name
+-- -----------------------------------------------------------------------
+
+
+"""
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropForeignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropForeignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropForeignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropForeignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+return """\
+ALTER TABLE $foreignKey.parent.name
+ DROP CONSTRAINT $foreignKey.name;
+
+
+"""
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropTable.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropTable.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropTable.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropTable.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,33 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Table table = torqueGenGroovy.model
+
+String dropSequence = ""
+if (table.idMethod == "native")
+{
+dropSequence = """DROP SEQUENCE $table.sequenceName;
+"""
+}
+
+return """\
+DROP TABLE $table.name CASCADE CONSTRAINTS;
+${dropSequence}"""
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropView.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropView.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropView.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/dropView.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,19 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+//
+// Drop view not necessary in Oracle
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/foreignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/foreignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/foreignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/foreignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,54 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+def result = """\
+ALTER TABLE $foreignKey.parent.name
+ ADD CONSTRAINT $foreignKey.name
+ FOREIGN KEY ($foreignKey.localColumnNames)
+ REFERENCES $foreignKey.foreignTable ($foreignKey.foreignColumnNames)"""
+if (foreignKey.onUpdate == "setnull")
+{
+ result += """
+ ON UPDATE SET NULL"""
+}
+else if (foreignKey.onUpdate)
+{
+ result += """
+ ON UPDATE ${foreignKey.onUpdate.toUpperCase()}"""
+}
+if (foreignKey.onDelete == "setnull")
+{
+ result += """
+
+ ON DELETE SET NULL"""
+}
+else if (foreignKey.onDelete)
+{
+ result += """
+
+ ON DELETE ${foreignKey.onDelete.toUpperCase()}"""
+}
+result += """;
+
+"""
+return result
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/index.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/index.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/index.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/index.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,38 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Index
+import org.apache.commons.lang.StringUtils
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Index index = torqueGenGroovy.model
+if (index.indexColumnNames != "")
+{
+ String indexName = index.name
+ if (StringUtils.isBlank(indexName))
+ {
+ indexName = ""
+ }
+ else
+ {
+ indexName = " " + indexName
+ }
+ return """\
+CREATE INDEX${indexName} ON $index.parent.name ($index.indexColumnNames);
+"""
+}
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/primaryKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/primaryKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/primaryKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/primaryKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,31 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Table table = torqueGenGroovy.model
+if (table.primaryKeyColumnNames != "")
+{
+ return """\
+ALTER TABLE $table.name
+ ADD CONSTRAINT ${table.primaryKeyConstraintName}
+ PRIMARY KEY($table.primaryKeyColumnNames);
+"""
+}
+
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/sequence.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/sequence.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/sequence.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/sequence.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+//
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Table table = torqueGenGroovy.model
+
+if (table.idMethod == "native")
+{
+ return """CREATE SEQUENCE $table.sequenceName INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER;
+"""
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,47 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Table table = torqueGenGroovy.model
+String cols = torqueGenGroovy.mergepoint("columns")
+String pk = torqueGenGroovy.mergepoint("primaryKey")
+String unique = torqueGenGroovy.mergepoint("unique")
+String index = torqueGenGroovy.mergepoint("index")
+String sequence = torqueGenGroovy.mergepoint("sequence")
+String createTableSql = "${cols}${unique}"
+int lastCommaPos = createTableSql.lastIndexOf(",")
+if (lastCommaPos != -1)
+{
+ createTableSql = createTableSql.substring(0, lastCommaPos)
+}
+
+def result = """
+-- -----------------------------------------------------------------------
+-- $table.name
+-- -----------------------------------------------------------------------
+CREATE TABLE $table.name
+(
+${createTableSql}${torqueGenGroovy.mergepoint("createOptions")}
+);
+
+${pk}
+${index}
+${sequence}
+"""
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableComment.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableComment.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableComment.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableComment.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,33 @@
+// 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
+//
+// 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.
+//
+// no Comments on columns in mysql
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Table
+import org.apache.commons.lang.StringUtils
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Table table = torqueGenGroovy.model
+if (StringUtils.isNotBlank(table.description))
+{
+ String columnComment = torqueGenGroovy.mergepoint("columnComment")
+
+ return """COMMENT ON TABLE ${table.name} IS '${table.description}';
+
+$columnComment
+"""
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableCreateOptions.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableCreateOptions.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableCreateOptions.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/tableCreateOptions.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,24 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+//
+//////////
+//
+// version $Id: tableCreateOptions.vm 1437184 2013-01-22 21:25:57Z tfischer $
+//
+// No table create options are implemented.
+//
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/unique.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/unique.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/unique.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/unique.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,26 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Unique
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Unique unique = torqueGenGroovy.model
+if (unique.uniqueColumnNames != "")
+{
+ return " CONSTRAINT ${unique.name} UNIQUE ($unique.uniqueColumnNames),"
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/view.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/view.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/view.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/view.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,47 @@
+package org.apache.torque.templates.sql.templates.ddl.oracle
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.View
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+View view = torqueGenGroovy.model
+if (!view.skipSql.equals("true"))
+{
+ if (view.createSql != null)
+ {
+ return view.createSql + """
+
+"""
+ }
+ else
+ {
+ String cols = torqueGenGroovy.mergepoint("columns")
+ int lastCommaPos = cols.lastIndexOf(",")
+ if (lastCommaPos != -1)
+ {
+ cols = cols.substring(0, lastCommaPos)
+ }
+
+ return """CREATE OR REPLACE VIEW ${view.name} AS
+ SELECT
+${cols}
+ ${view.sqlSuffix};
+
+"""
+ }
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/columnComment.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/columnComment.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/columnComment.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/columnComment.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,29 @@
+// 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
+//
+// 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.
+//
+// no Comments on columns in mysql
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Column
+import org.apache.commons.lang.StringUtils
+
+TorqueGenGroovy torqueGenGroovy = torqueGen
+Column column = torqueGenGroovy.model
+if (StringUtils.isNotBlank(column.description))
+{
+ return """COMMENT ON COLUMN ${column.parent.name}.${column.name} IS '${column.description}';
+"""
+}
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/databaseStart.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/databaseStart.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/databaseStart.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/databaseStart.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,28 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.Database
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+Database database = torqueGenGroovy.model
+return """\
+-- -----------------------------------------------------------------------
+-- ${torqueGenGroovy.getOption("torque.database")} SQL script for schema $database.name
+-- -----------------------------------------------------------------------
+
+
+"""
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/dropForeignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/dropForeignKey.groovy?rev=1478984&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/dropForeignKey.groovy (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/dropForeignKey.groovy Fri May 3 21:25:27 2013
@@ -0,0 +1,28 @@
+// 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
+//
+// 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.
+import org.apache.torque.generator.template.groovy.TorqueGenGroovy
+import org.apache.torque.templates.model.ForeignKey
+
+TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
+ForeignKey foreignKey = torqueGenGroovy.model
+
+return """\
+ALTER TABLE $foreignKey.parent.name
+ DROP CONSTRAINT $foreignKey.name;
+
+
+"""
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org