db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1574676 - /db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/write-to-db.xml
Date Wed, 05 Mar 2014 21:34:39 GMT
Author: tfischer
Date: Wed Mar  5 21:34:39 2014
New Revision: 1574676

URL: http://svn.apache.org/r1574676
Log:
add insert ... select ... docs

Modified:
    db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/write-to-db.xml

Modified: db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/write-to-db.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/write-to-db.xml?rev=1574676&r1=1574675&r2=1574676&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/write-to-db.xml
(original)
+++ db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/write-to-db.xml
Wed Mar  5 21:34:39 2014
@@ -27,7 +27,7 @@
  </properties>
 
  <body>
-  <section name="Saving an object (inserts and updates)">
+  <section name="Saving an object (simple inserts and updates)">
 
     <p>
       To write an object into the database, call its save() method.  Depending 
@@ -213,6 +213,32 @@ BasePeer.doUpdate(criteria, columnValues
 
   </section>
   
+  <section name="insert ... select ... statements">
+    <p>
+      The supported Databases allow to insert values which are previously
+      selected from the database, using an insert ... select ... statement.
+      These statements can be created using a special doInsert method
+      in the Peer classes: The first argument is an array of Column
+      objects which define the columns where the data is inserted
+      (all these columns must be in one table, though this is not checked
+      by Torque), and the second argument is a Criteria which
+      select the values to be inserted from the database (this criteria
+      must select the same number of columns as are in the first array,
+      although again this is not checked by Torque).
+      As an example (which makes no sense in a logical sense), 
+      we can insert a number of authors into the author table, 
+      setting the name of the inserted authors to the title of all books
+      in the database: 
+    </p>
+
+<source>
+    int numberOfInsertedRows = AuthorPeer.doInsert(
+            new Column[] {AuthorPeer.NAME},
+            new Criteria().addSelectColumn(BookPeer.TITLE));
+</source>
+
+  </section>
+  
   <section name="Deleting objects">
     <p>
       If you want to delete an author which was already loaded into memory,



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message