diff --git a/jOOQ-scala/src/main/scala/org/jooq/scala/Conversions.scala b/jOOQ-scala/src/main/scala/org/jooq/scala/Conversions.scala
index 1f52d63692..2f571d9083 100644
--- a/jOOQ-scala/src/main/scala/org/jooq/scala/Conversions.scala
+++ b/jOOQ-scala/src/main/scala/org/jooq/scala/Conversions.scala
@@ -306,6 +306,11 @@ object Conversions {
case _ => new AnyFieldWrapper(f)
}
+ // --------------------------------------------------------------------------
+ // Conversions from jOOQ Record[N] types to Scala Tuple[N] types
+ // --------------------------------------------------------------------------
+
+// [jooq-tools] START [tuples]
/**
* Enrich any {@link org.jooq.Record1} with the {@link Tuple1} case class
*/
@@ -369,4 +374,7 @@ object Conversions {
case null => null
case _ => Tuple8(r.value1, r.value2, r.value3, r.value4, r.value5, r.value6, r.value7, r.value8)
}
+
+// [jooq-tools] END [tuples]
+
}
diff --git a/jOOQ-tools/src/org/jooq/xtend/Conversions.xtend b/jOOQ-tools/src/org/jooq/xtend/Conversions.xtend
new file mode 100644
index 0000000000..594bc09fb1
--- /dev/null
+++ b/jOOQ-tools/src/org/jooq/xtend/Conversions.xtend
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
+ * All rights reserved.
+ *
+ * This software is licensed to you under the Apache License, Version 2.0
+ * (the "License"); You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * . Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * . Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * . Neither the name "jOOQ" nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.jooq.xtend
+
+import org.jooq.Constants
+
+/**
+ * @author Lukas Eder
+ */
+class Conversions extends Generators {
+
+ def static void main(String[] args) {
+ val conversions = new Conversions();
+ conversions.generateConversions();
+ }
+
+ def generateConversions() {
+ val out = new StringBuilder();
+
+ out.append('''
+ «FOR degree : (1..Constants::MAX_ROW_DEGREE)»
+
+ /**
+ * Enrich any {@link org.jooq.Record«degree»} with the {@link Tuple«degree»} case class
+ */
+ implicit def asTuple«degree»[«TN(degree)»](r : Record«degree»[«TN(degree)»]): Tuple«degree»[«TN(degree)»] = r match {
+ case null => null
+ case _ => Tuple«degree»(«FOR d : (1..degree) SEPARATOR ', '»r.value«d»«ENDFOR»)
+ }
+ «ENDFOR»
+ ''');
+
+ insert("org.jooq.scala.Conversions", out, "tuples");
+ }
+}
\ No newline at end of file
diff --git a/jOOQ-tools/src/org/jooq/xtend/GenerateAll.xtend b/jOOQ-tools/src/org/jooq/xtend/GenerateAll.xtend
new file mode 100644
index 0000000000..6b53b1ed74
--- /dev/null
+++ b/jOOQ-tools/src/org/jooq/xtend/GenerateAll.xtend
@@ -0,0 +1,11 @@
+package org.jooq.xtend
+
+class GenerateAll {
+ def static void main(String[] args) {
+ Conversions::main(args);
+ Factory::main(args);
+ Records::main(args);
+ Rows::main(args);
+ Update::main(args);
+ }
+}
\ No newline at end of file
diff --git a/jOOQ-tools/src/org/jooq/xtend/Generators.xtend b/jOOQ-tools/src/org/jooq/xtend/Generators.xtend
index 8b28e5c28f..a21a44cdc3 100644
--- a/jOOQ-tools/src/org/jooq/xtend/Generators.xtend
+++ b/jOOQ-tools/src/org/jooq/xtend/Generators.xtend
@@ -45,8 +45,17 @@ import java.io.RandomAccessFile
*/
abstract class Generators {
+ def file(String className) {
+ if (className.contains("scala")) {
+ return new File("./../jOOQ-scala/src/main/scala/" + className.replace(".", "/") + ".scala");
+ }
+ else {
+ return new File("./../jOOQ/src/main/java/" + className.replace(".", "/") + ".java");
+ }
+ }
+
def read(String className) {
- val file = new File("./../jOOQ/src/main/java/" + className.replace(".", "/") + ".java");
+ val file = file(className)
try {
val f = new RandomAccessFile(file, "r");
@@ -74,7 +83,7 @@ abstract class Generators {
}
def write(String className, CharSequence contents) {
- val file = new File("./../jOOQ/src/main/java/" + className.replace(".", "/") + ".java");
+ val file = file(className);
file.getParentFile().mkdirs();
try {
diff --git a/jOOQ-tools/src/org/jooq/xtend/Update.xtend b/jOOQ-tools/src/org/jooq/xtend/Update.xtend
new file mode 100644
index 0000000000..da6ce66cf2
--- /dev/null
+++ b/jOOQ-tools/src/org/jooq/xtend/Update.xtend
@@ -0,0 +1,190 @@
+/**
+ * Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
+ * All rights reserved.
+ *
+ * This software is licensed to you under the Apache License, Version 2.0
+ * (the "License"); You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * . Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * . Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * . Neither the name "jOOQ" nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.jooq.xtend
+
+import org.jooq.Constants
+
+/**
+ * @author Lukas Eder
+ */
+class Update extends Generators {
+
+ def static void main(String[] args) {
+ val update = new Update();
+ update.generateUpdateQuery();
+ update.generateUpdateQueryImpl();
+ update.generateUpdateSetFirstStep();
+ update.generateUpdateImpl();
+ }
+
+ def generateUpdateQuery() {
+ val out = new StringBuilder();
+
+ out.append('''
+ «FOR degree : (1..Constants::MAX_ROW_DEGREE)»
+
+ /**
+ * Specify a multi-column set clause for the UPDATE statement.
+ */
+ «generatedMethod»
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ <«TN(degree)»> void addValues(Row«degree»<«TN(degree)»> row, Row«degree»<«TN(degree)»> value);
+ «ENDFOR»
+ «FOR degree : (1..Constants::MAX_ROW_DEGREE)»
+
+ /**
+ * Specify a multi-column set clause for the UPDATE statement.
+ */
+ «generatedMethod»
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ <«TN(degree)»> void addValues(Row«degree»<«TN(degree)»> row, Select extends Record«degree»<«TN(degree)»>> select);
+ «ENDFOR»
+ ''');
+
+ insert("org.jooq.UpdateQuery", out, "addValues");
+ }
+
+ def generateUpdateQueryImpl() {
+ val out = new StringBuilder();
+
+ out.append('''
+ «FOR degree : (1..Constants::MAX_ROW_DEGREE)»
+
+ «generatedMethod»
+ @Override
+ public final <«TN(degree)»> void addValues(Row«degree»<«TN(degree)»> row, Row«degree»<«TN(degree)»> value) {
+ addValues0(row, value);
+ }
+ «ENDFOR»
+ «FOR degree : (1..Constants::MAX_ROW_DEGREE)»
+
+ «generatedMethod»
+ @Override
+ public final <«TN(degree)»> void addValues(Row«degree»<«TN(degree)»> row, Select extends Record«degree»<«TN(degree)»>> select) {
+ addValues0(row, select);
+ }
+ «ENDFOR»
+ ''');
+
+ insert("org.jooq.impl.UpdateQueryImpl", out, "addValues");
+ }
+
+ def generateUpdateSetFirstStep() {
+ val out = new StringBuilder();
+
+ out.append('''
+ «classHeader»
+ package org.jooq;
+
+ import static org.jooq.SQLDialect.DB2;
+ import static org.jooq.SQLDialect.H2;
+ import static org.jooq.SQLDialect.HSQLDB;
+ import static org.jooq.SQLDialect.INGRES;
+ import static org.jooq.SQLDialect.ORACLE;
+ import static org.jooq.SQLDialect.POSTGRES;
+
+ import javax.annotation.Generated;
+
+ /**
+ * This type is used for the {@link Update}'s DSL API.
+ *
+ * Example:
+ * This is simulated using a subquery for the
* Example:
+ *
+ * @author Lukas Eder
+ */
+ «generatedAnnotation»
+ public interface UpdateSetFirstStep
+ * Executor create = new Executor(connection, dialect);
+ *
+ * create.update(table)
+ * .set(field1, value1)
+ * .set(field2, value2)
+ * .where(field1.greaterThan(100))
+ * .execute();
+ *
UPDATE statement.
+ * value, where row
+ * value expressions aren't supported.
+ */
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ <«TN(degree)»> UpdateWhereStepUPDATE statement.
+ */
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ <«TN(degree)»> UpdateWhereStepUPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
+ */
+ @Generated("This method was generated using jOOQ-tools")
+ @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
+ UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE, POSTGRES })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
- UPDATE statement.
- */
- @Support({ DB2, H2, HSQLDB, INGRES, ORACLE })
-
- * Factory create = new Factory();
+ * Executor create = new Executor(connection, dialect);
*
* create.update(table)
* .set(field1, value1)
@@ -57,6 +59,7 @@ import static org.jooq.SQLDialect.POSTGRES;
*
* @author Lukas Eder
*/
+@Generated("This class was generated using jOOQ-tools")
public interface UpdateSetFirstStep