Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 39235 invoked from network); 16 Feb 2010 17:17:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Feb 2010 17:17:39 -0000 Received: (qmail 541 invoked by uid 500); 16 Feb 2010 17:17:39 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 518 invoked by uid 500); 16 Feb 2010 17:17:39 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 508 invoked by uid 500); 16 Feb 2010 17:17:39 -0000 Received: (qmail 505 invoked by uid 99); 16 Feb 2010 17:17:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2010 17:17:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2010 17:17:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 26D462388C32; Tue, 16 Feb 2010 17:16:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r910600 [27/29] - in /db/torque/torque4/trunk: maven-torque-gf-plugin/ maven-torque-gf-plugin/src/ maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/ maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/m... Date: Tue, 16 Feb 2010 17:16:02 -0000 To: torque-commits@db.apache.org From: tfischer@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100216171614.26D462388C32@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classJavadoc.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classJavadoc.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classJavadoc.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classJavadoc.vm Tue Feb 16 17:15:43 2010 @@ -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. +## +###### +## +## version $Id: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the class javadoc for a base peer object. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## +/** +#if ($description) + * $description + * +#end +#if ($torqueGf.booleanOption("torque.om.addTimeStamp")) + * The skeleton for this class was autogenerated by Torque on: + * + * [${torqueGf.now()}] + * +#end + * You should not use this class directly. It should not even be + * extended; all references should be to $peerClassName + */ Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classMethods.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classMethods.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classMethods.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classMethods.vm Tue Feb 16 17:15:43 2010 @@ -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. +## +###### +## +## version $Id: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the methods for class handling. +## This template expects no input. +## + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + log.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Torque developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propagated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstant.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstant.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstant.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstant.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,32 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the constants for the column names in the base peer class. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + + /** the column name for the ${name} field */ + public static final String ${peerColumnName}; Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstantInit.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstantInit.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstantInit.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/columnConstantInit.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,30 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Initializes the constants for the column names in the base peer class. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + ${peerColumnName} = "${qualifiedColumnName}"; Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/correctBooleans.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/correctBooleans.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/correctBooleans.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/correctBooleans.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,42 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the correctBooleans method for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * changes the boolean values in the criteria to the appropriate type, + * whenever a booleanchar or booleanint column is involved. + * This enables the user to create criteria using Boolean values + * for booleanchar or booleanint columns + * @param criteria the criteria in which the boolean values should be corrected + * @throws TorqueException if the database map for the criteria cannot be + obtained. + */ + public static void correctBooleans(Criteria criteria) throws TorqueException + { + ${peerClassName}.correctBooleans(criteria, getTableMap()); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,68 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the constants for the class of the database object. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "${dbObjectPackage}.${dbObjectClassName}"; + + /** A class that can be returned by this peer. */ + protected static final Class#if($java5 == "true")#end CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + +#set ($inheritanceColumnBaseElement = $torqueGf.getChild("inheritance-column")) +#if ($inheritanceColumnBaseElement) + #set ( $columnElement = $inheritanceColumnBaseElement.getChild("column") ) + #set ( $inheritanceElements = $columnElement.getChildren("inheritance")) + ## NOTE: this hack requires a class type definition column to + ## be a primitive type or a String. Should not be a bad assumption + #if ($columnElement.getAttribute("primitive") == "true") + #set ($quote = "") + #else + #set ($quote = '"') + #end + #set ( $fieldType = $columnElement.getAttribute("fieldType") ) + #foreach ($inheritanceElement in $inheritanceElements) + #set ( $key = $inheritanceElement.getAttribute("key") ) + #set ( $class = $inheritanceElement.getAttribute("class") ) + #set ( $classConstant = $inheritanceElement.getAttribute("classConstant") ) + #set ( $classkeyConstant = $inheritanceElement.getAttribute("classkeyConstant") ) + #set ( $classnameConstant = $inheritanceElement.getAttribute("classnameConstant") ) + /** A key representing a particular subclass */ + public static final $fieldType $classkeyConstant = + $quote$key$quote; + + /** A class that can be returned by this peer. */ + public static final String $classnameConstant = + "${dbObjectPackage}.$class"; + + /** A class that can be returned by this peer. */ + public static final Class#if($java5 == "true")#end $classConstant = + initClass($classnameConstant); + + #end +#end Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,121 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doDelete methods for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + ${peerClassName}.doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + ${peerClassName}.correctBooleans(criteria); + + setDbName(criteria); + + if (con == null) + { + BasePeer.doDelete(criteria, TABLE_NAME); + } + else + { + BasePeer.doDelete(criteria, TABLE_NAME, con); + } + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete($dbObjectClassName obj) throws TorqueException + { + ${peerClassName}.doDelete(${peerClassName}.buildSelectCriteria(obj)); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete($dbObjectClassName) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete($dbObjectClassName obj, Connection con) + throws TorqueException + { + ${peerClassName}.doDelete(${peerClassName}.buildSelectCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + ${peerClassName}.doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + ${peerClassName}.doDelete(${peerClassName}.buildCriteria(pk), con); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,109 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doInsert methods for a base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return ${peerClassName}.doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + ${peerClassName}.correctBooleans(criteria); + + setDbName(criteria); + + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert($dbObjectClassName obj) throws TorqueException + { + #if ($idMethod.equals("none") || $torqueGf.getChild("primary-keys").getChildren("column").isEmpty()) + ${peerClassName}.doInsert(${peerClassName}.buildCriteria(obj)); + #else + obj.setPrimaryKey(${peerClassName}.doInsert( + ${peerClassName}.buildCriteria(obj))); + #end + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert($dbObjectClassName) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert($dbObjectClassName obj, Connection con) + throws TorqueException + { + #if ($idMethod.equals("none") || $torqueGf.getChild("primary-keys").getChildren("column").isEmpty()) + ${peerClassName}.doInsert(${peerClassName}.buildCriteria(obj), con); + #else + obj.setPrimaryKey(${peerClassName}.doInsert( + ${peerClassName}.buildCriteria(obj), con)); + #end + obj.setNew(false); + obj.setModified(false); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,69 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doSelect methods for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List#if($java5 == "true")<${dbObjectClassName}>#end doSelect(Criteria criteria) throws TorqueException + { + return ${peerClassName}.populateObjects( + ${peerClassName}.doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List#if($java5 == "true")<${dbObjectClassName}>#end doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return ${peerClassName}.populateObjects( + ${peerClassName}.doSelectVillageRecords(criteria, con)); + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List#if($java5 == "true")<${dbObjectClassName}>#end doSelect($dbObjectClassName obj) throws TorqueException + { + return ${peerClassName}.doSelect(${peerClassName}.buildSelectCriteria(obj)); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,146 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doSelectJoinXXX methods for the base peer. +## +## This template expects the current source element to be a "foreign-field" +## element from the schema, processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## +#set ( $foreignKeyElement = $torqueGf.getParent() ) +#set ( $tableElement = $foreignKeyElement.getParent() ) +#set ( $joinedTableElement = $foreignKeyElement.getChild("table") ) +#set ( $dbObjectClassName = $tableElement.getAttribute("dbObjectClassName") ) +#set ( $joinedDbObjectClassName = $joinedTableElement.getAttribute("dbObjectClassName") ) +#set ( $joinedDbObjectPackage = $joinedTableElement.getAttribute("dbObjectPackage") ) +#set ( $joinedDbObject = "${joinedDbObjectPackage}.$joinedDbObjectClassName" ) +#set ( $peerClassName = $tableElement.getAttribute("peerClassName") ) +#set ( $joinedPeerClassName = $joinedTableElement.getAttribute("peerClassName") ) +#set ( $joinedPeerPackage = $joinedTableElement.getAttribute("peerPackage") ) +#set ( $joinedPeer = "${joinedPeerPackage}.$joinedPeerClassName" ) +#set ( $referenceElements = $foreignKeyElement.getChildren("reference") ) +#set ( $localFieldElement = $foreignKeyElement.getChild("local-field")) +#set ( $getterForJoinedDbObject = $localFieldElement.getAttribute("getter")) + /** + * selects a collection of dbObjectClassName objects pre-filled with their + * $joinedDbObjectClassName objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ${peerClassName}. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List#if($java5 == "true")<$dbObjectClassName>#end ${peerJoinSelectMethod}(Criteria criteria) + throws TorqueException + { + return $peerClassName.${peerJoinSelectMethod}(criteria, null); + } + + /** + * selects a collection of $dbObjectClassName objects pre-filled with their + * $joinedDbObjectClassName objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in $peerClassName. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List#if($java5 == "true")<$dbObjectClassName>#end ${peerJoinSelectMethod}(Criteria criteria, Connection conn) + throws TorqueException + { + setDbName(criteria); + + ${peerClassName}.addSelectColumns(criteria); + int offset = numColumns + 1; + ${joinedPeer}.addSelectColumns(criteria); + + #foreach ($referenceElement in $referenceElements) + #set ( $joinedColumnElement = $referenceElement.getChild("foreign-column").getChild("column") ) + #set ( $joinedPeerColumnName = $joinedColumnElement.getAttribute("peerColumnName") ) + #set ( $columnElement = $referenceElement.getChild("local-column").getChild("column") ) + #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") ) + criteria.addJoin($peerClassName.$peerColumnName, + $joinedPeer.$joinedPeerColumnName); + #end + + correctBooleans(criteria); + + List#if($java5 == "true")#end rows; + if (conn == null) + { + rows = BasePeer.doSelect(criteria); + } + else + { + rows = BasePeer.doSelect(criteria, conn); + } + + List#if($java5 == "true")<$dbObjectClassName>#end results = new ArrayList#if($java5 == "true")<$dbObjectClassName>#end(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = #if($java5 != "true")(Record)#end rows.get(i); + + #if ($tableElement.getChild("inheritance-column")) + Class omClass = ${peerClassName}.getOMClass(row, 1); + #else + Class omClass = ${peerClassName}.getOMClass(); + #end + $dbObjectClassName obj1 = $peerClassName + .row2Object(row, 1, omClass); + #if ($otherTableElement.getChild("inheritance-column")) + omClass = ${joinedPeer}.getOMClass(row, offset); + #else + omClass = ${joinedPeer}.getOMClass(); + #end + $joinedDbObjectClassName obj2 = $joinedPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + $dbObjectClassName temp_obj1 = #if($java5 != "true")($dbObjectClassName)#end results.get(j); + $joinedDbObject temp_obj2 = temp_obj1.${getterForJoinedDbObject}(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + #if ($objectIsCaching) + temp_obj2.${adder}(obj1); + #end + break; + } + } + #if ($objectIsCaching) + if (newObject) + { + obj2.${initializer}(); + obj2.${adder}(obj1); + } + #end + results.add(obj1); + } + return results; + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,190 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doSelectJoinAllExceptXXX methods for the base peer class. +## +## This template expects the current source element to be a "foreign-field" +## element from the torque schema which was processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## +#set ( $foreignKeyElement = $torqueGf.getParent() ) +#set ( $tableElement = $foreignKeyElement.getParent() ) +#set ( $foreignKeyElements = $tableElement.getChildren("foreign-key")) +#if ($foreignKeyElements.size() > 2) + #set ( $tableName = $tableElement.getAttribute("name") ) + #set ( $excludeTableElement = $foreignKeyElement.getChild("table") ) + #set ( $peerClassName = $tableElement.getAttribute("peerClassName") ) + #set ( $peerPackage = $tableElement.getAttribute("peerPackage") ) + #set ( $peer = "${peerPackage}.$peerClassName" ) + #set ( $dbObjectClassName = $tableElement.getAttribute("dbObjectClassName") ) + #set ( $dbObjectPackage = $tableElement.getAttribute("dbObjectPackage") ) + #set ( $dbObject = "${dbObjectPackage}.$dbObjectClassName" ) + /** + * selects a collection of $dbObjectClassName objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ${peerClassName}. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List#if($java5 == "true")<${dbObjectClassName}>#end ${peerJoinAllExceptSelectMethod}(Criteria criteria) + throws TorqueException + { + return ${peerJoinAllExceptSelectMethod}(criteria, null); + } + + /** + * selects a collection of $dbObjectClassName objects pre-filled with + * related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ${peerClassName}. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List#if($java5 == "true")<${dbObjectClassName}>#end ${peerJoinAllExceptSelectMethod}(Criteria criteria, Connection conn) + throws TorqueException + { + setDbName(criteria); + + ${peer}.addSelectColumns(criteria); + int offset2 = numColumns + 1; + #set ( $index = 2 ) + #foreach ($joinedForeignKeyElement in $foreignKeyElements) + #if ($joinedForeignKeyElement != $foreignKeyElement) + #set ( $joinedTableElement = $joinedForeignKeyElement.getChild("table")) + #set ( $joinedTableName = $joinedTableElement.getAttribute("name")) + ## want to cover this case, but the code is not there yet. + #if ( $joinedTableName != $tableName ) + #set ( $joinedPeerClassName = $joinedTableElement.getAttribute("peerClassName") ) + #set ( $joinedPeerPackage = $joinedTableElement.getAttribute("peerPackage") ) + #set ( $joinedPeer = "${joinedPeerPackage}.${joinedPeerClassName}" ) + #set ( $referenceElements = $joinedForeignKeyElement.getChildren("reference") ) + + ${joinedPeer}.addSelectColumns(criteria); + #foreach ($referenceElement in $referenceElements) + #set ( $columnElement = $referenceElement.getChild("local-column").getChild("column")) + #set ( $joinedColumnElement = $referenceElement.getChild("foreign-column").getChild("column")) + #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") ) + #set ( $joinedPeerColumnName = $joinedColumnElement.getAttribute("peerColumnName") ) + criteria.addJoin(${peer}.$peerColumnName, ${joinedPeer}.$joinedPeerColumnName); + #end + #if($index < $foreignKeyElements.size()) + #set ( $new_index = $index + 1 ) + int offset$new_index = offset$index + ${joinedPeer}.numColumns; + #set ( $index = $new_index ) + #end + #end + #end + #end + + correctBooleans(criteria); + + List#if($java5 == "true")#end rows; + if (conn == null) + { + rows = BasePeer.doSelect(criteria); + } + else + { + rows = BasePeer.doSelect(criteria,conn); + } + + List#if($java5 == "true")<${dbObjectClassName}>#end results = new ArrayList#if($java5 == "true")<${dbObjectClassName}>#end(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = #if(!$java5 == "true")(Record)#end rows.get(i); + + #if ($tableElement.getChild("inheritance-column")) + Class omClass = ${peer}.getOMClass(row, 1); + #else + Class omClass = ${peer}.getOMClass(); + #end + $dbObject obj1 = $peer + .row2Object(row, 1, omClass); + #set ( $index = 1 ) + #foreach ($joinedForeignKeyElement in $foreignKeyElements) + #if ($joinedForeignKeyElement != $foreignKeyElement) + #set ( $joinedTableElement = $joinedForeignKeyElement.getChild("table")) + #set ( $joinedTableName = $joinedTableElement.getAttribute("name")) + ## want to cover this case, but the code is not there yet. + #if ( $joinedTableName != $tableName ) + #set ( $joinedPeerClassName = $joinedTableElement.getAttribute("peerClassName") ) + #set ( $joinedPeerPackage = $joinedTableElement.getAttribute("peerPackage") ) + #set ( $joinedPeer = "${joinedPeerPackage}.${joinedPeerClassName}" ) + #set ( $joinedDbObjectClassName = $joinedTableElement.getAttribute("dbObjectClassName") ) + #set ( $joinedDbObjectPackage = $joinedTableElement.getAttribute("dbObjectPackage") ) + #set ( $joinedDbObject = "${joinedDbObjectPackage}.${joinedDbObjectClassName}" ) + #set ( $foreignField = $joinedForeignKeyElement.getChild("foreign-field") ) + #set ( $adderInJoinedDbObject = $foreignField.getAttribute("adder") ) + #set ( $initializerInJoinedDbObject = $foreignField.getAttribute("initializer") ) + #set ( $localField = $joinedForeignKeyElement.getChild("local-field") ) + #set ( $getter = $localField.getAttribute("getter") ) + #set ( $index = $index + 1 ) + + #if ($joinedTableElement.getChild("inheritance-column")) + omClass = ${joinedPeer}.getOMClass(row, offset$index); + #else + omClass = ${joinedPeer}.getOMClass(); + #end + $joinedDbObject obj$index = ${joinedPeer} + .row2Object( row, offset$index, omClass); + #if ($index == 2) + #set ( $boolean = "boolean " ) + #else + #set ( $boolean = "") + #end + ${boolean}newObject = true; + for (int j = 0; j < results.size(); j++) + { + $dbObject temp_obj1 = #if(!$java5 == "true")($dbObject)#end results.get(j); + $joinedDbObject temp_obj$index = temp_obj1.${getter}(); + if (temp_obj${index}.getPrimaryKey().equals(obj${index}.getPrimaryKey())) + { + newObject = false; + #if ($objectIsCaching) + temp_obj${index}.${adderInJoinedDbObject}(obj1); + #end + break; + } + } + #if ($objectIsCaching) + if (newObject) + { + obj${index}.${initializerInJoinedDbObject}(); + obj${index}.${adderInJoinedDbObject}(obj1); + } + #end + #end + #end + #end + results.add(obj1); + } + return results; + } +#end Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectVillageRecords.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectVillageRecords.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectVillageRecords.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectVillageRecords.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,76 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doSelectVillageRecords methods for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List#if($java5 == "true")#end doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return ${peerClassName}.doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List#if($java5 == "true")#end doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + if (criteria.getSelectColumns().size() == 0) + { + ${peerClassName}.addSelectColumns(criteria); + } + ${peerClassName}.correctBooleans(criteria); + + setDbName(criteria); + + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,119 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the doUpdate methods for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + ${peerClassName}.doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + ${peerClassName}.correctBooleans(criteria); + +#foreach ($columnElement in $torqueGf.getChildren("column")) + + #if($columnElement.getAttribute("primaryKey") == "true") + #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") ) + + selectCriteria.put( + ${peerClassName}.$peerColumnName, + criteria.remove(${peerClassName}.$peerColumnName)); + #end +#end + + setDbName(criteria); + + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate($dbObjectClassName obj) throws TorqueException + { +#if ($torqueGf.getChild("primary-keys").getChildren("column").isEmpty()) + throw new TorqueException( + "doUpdate does not work for objects without primary key"); +#else + ${peerClassName}.doUpdate(${peerClassName}.buildCriteria(obj)); + obj.setModified(false); +#end + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate($dbObjectClassName) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate($dbObjectClassName obj, Connection con) + throws TorqueException + { + #if ($torqueGf.getChild("primary-keys").getChildren("column").isEmpty()) + throw new TorqueException( + "doUpdate does not work for objects without primary key"); + #else + ${peerClassName}.doUpdate(${peerClassName}.buildCriteria(obj), con); + obj.setModified(false); + #end + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,107 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the getOMClass method(s) for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## +#set ( $inheritanceBaseColumnElement = $torqueGf.getChild("inheritance-column") ) +#if ($inheritanceBaseColumnElement) + #set ( $columnElement = $inheritanceBaseColumnElement.getChild("column") ) + /** + * The returned Class will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass(Record record, int offset) + throws TorqueException + { + Class omClass; + try + { + #set ($inheritanceElements = $columnElement.getChildren("inheritance")) + #set ( $fieldType = $columnElement.getAttribute("fieldType") ) + #set ( $villageMethod = $columnElement.getAttribute("villageMethod") ) + #set ( $position = $columnElement.getAttribute("position") ) + #set ( $primitive = ($columnElement.getAttribute("primitive") == "true") ) + #if (!$inheritanceElements.isEmpty()) + $fieldType classKey = + record.getValue(offset - 1 + $position) + .$villageMethod; + #set ($if = "if") + #foreach ($inheritanceElement in $inheritanceElements) + #set ( $classkeyConstant = $inheritanceElement.getAttribute("classkeyConstant") ) + #set ( $classConstant = $inheritanceElement.getAttribute("classConstant") ) + #if ($primitive) + $if (classKey == $classkeyConstant) + #else + $if (${classkeyConstant}.equals(classKey)) + #end + { + omClass = ${peerClassName}.$classConstant; + } + #set ($if = "else if") + #end + else + { + omClass = ${peerClassName}.getOMClass(); + } + #else + omClass = Class.forName( + record.getValue(offset - 1 + $position).asString()); + #end + } + catch (Exception e) + { + throw new TorqueException(e); + } + return omClass; + } +#end + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { +#if ($abstract == "true") + String error = "You must implement the getOMClass method in your"; + error += " Peer object in order for things to work properly."; + error += " This method should return the proper Class that"; + error += " represents the Peer's Business Object."; + throw new TorqueException (error); +#else + return ${peerClassName}.CLASS_DEFAULT; +#end + } + Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getTableMap.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getTableMap.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getTableMap.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getTableMap.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,35 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the addSelectColumns method for the base peer. +## This template expects no input. +## + /** + * Returns the TableMap related to this peer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,57 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Generates the import statements for the base peer class +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.NoRowsException; +import org.apache.torque.TooManyRowsException; +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.TorqueRuntimeException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +import ${mapBuilderPackage}.*; Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/java5Wrappers.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/java5Wrappers.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/java5Wrappers.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/java5Wrappers.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,268 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the java5 wrappers method for the base peer. +## This template expects no input. +## + // The following methods wrap some methods in BasePeer + // to have more support for Java5 generic types in the Peer + + /** + * Utility method which executes a given sql statement. This + * method should be used for select statements only. Use + * executeStatement for update, insert, and delete operations. + * + * @param queryString A String with the sql statement to execute. + * @return List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#executeQuery(String) + */ + public static List executeQuery(String queryString) throws TorqueException + { + return BasePeer.executeQuery(queryString); + } + + /** + * Utility method which executes a given sql statement. This + * method should be used for select statements only. Use + * executeStatement for update, insert, and delete operations. + * + * @param queryString A String with the sql statement to execute. + * @param dbName The database to connect to. + * @return List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#executeQuery(String,String) + */ + public static List executeQuery(String queryString, String dbName) + throws TorqueException + { + return BasePeer.executeQuery(queryString,dbName); + } + + + /** + * Method for performing a SELECT. Returns all results. + * + * @param queryString A String with the sql statement to execute. + * @param dbName The database to connect to. + * @param singleRecord Whether or not we want to select only a + * single record. + * @return List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#executeQuery(String,String,boolean) + */ + public static List executeQuery( + String queryString, + String dbName, + boolean singleRecord) + throws TorqueException + { + return BasePeer.executeQuery(queryString,dbName,singleRecord); + } + + /** + * Method for performing a SELECT. Returns all results. + * + * @param queryString A String with the sql statement to execute. + * @param singleRecord Whether or not we want to select only a + * single record. + * @param con A Connection. + * @return List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#executeQuery(String,boolean,Connection) + */ + public static List executeQuery( + String queryString, + boolean singleRecord, + Connection con) + throws TorqueException + { + return BasePeer.executeQuery(queryString,singleRecord,con); + } + + /** + * Method for performing a SELECT. + * + * @param queryString A String with the sql statement to execute. + * @param start The first row to return. + * @param numberOfResults The number of rows to return. + * @param dbName The database to connect to. + * @param singleRecord Whether or not we want to select only a + * single record. + * @return List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean) + */ + public static List executeQuery( + String queryString, + int start, + int numberOfResults, + String dbName, + boolean singleRecord) + throws TorqueException + { + return BasePeer.executeQuery(queryString,start,numberOfResults,dbName,singleRecord); + } + + /** + * Method for performing a SELECT. Returns all results. + * + * @param queryString A String with the sql statement to execute. + * @param start The first row to return. + * @param numberOfResults The number of rows to return. + * @param singleRecord Whether or not we want to select only a + * single record. + * @param con A Connection. + * @return List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean,Connection) + */ + public static List executeQuery( + String queryString, + int start, + int numberOfResults, + boolean singleRecord, + Connection con) + throws TorqueException + { + return BasePeer.executeQuery(queryString,start,numberOfResults,singleRecord,con); + } + + /** + * Returns all records in a QueryDataSet as a List of Record + * objects. Used for functionality like util.LargeSelect. + * + * @see #getSelectResults(QueryDataSet, int, int, boolean) + * @param qds the QueryDataSet + * @return a List of Record objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet) + */ + public static List getSelectResults(QueryDataSet qds) + throws TorqueException + { + return BasePeer.getSelectResults(qds); + } + + /** + * Returns all records in a QueryDataSet as a List of Record + * objects. Used for functionality like util.LargeSelect. + * + * @see #getSelectResults(QueryDataSet, int, int, boolean) + * @param qds the QueryDataSet + * @param singleRecord + * @return a List of Record objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,boolean) + */ + public static List getSelectResults(QueryDataSet qds, boolean singleRecord) + throws TorqueException + { + return BasePeer.getSelectResults(qds,singleRecord); + } + + /** + * Returns numberOfResults records in a QueryDataSet as a List + * of Record objects. Starting at record 0. Used for + * functionality like util.LargeSelect. + * + * @see #getSelectResults(QueryDataSet, int, int, boolean) + * @param qds the QueryDataSet + * @param numberOfResults + * @param singleRecord + * @return a List of Record objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,boolean) + */ + public static List getSelectResults( + QueryDataSet qds, + int numberOfResults, + boolean singleRecord) + throws TorqueException + { + return BasePeer.getSelectResults(qds,numberOfResults,singleRecord); + } + + /** + * Returns numberOfResults records in a QueryDataSet as a List + * of Record objects. Starting at record start. Used for + * functionality like util.LargeSelect. + * + * @param qds The QueryDataSet to extract results + * from. + * @param start The index from which to start retrieving + * Record objects from the data set. + * @param numberOfResults The number of results to return (or + * -1 for all results). + * @param singleRecord Whether or not we want to select only a + * single record. + * @return A List of Record objects. + * @exception TorqueException If any Exception occurs. + * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,int,boolean) + */ + public static List getSelectResults( + QueryDataSet qds, + int start, + int numberOfResults, + boolean singleRecord) + throws TorqueException + { + return BasePeer.getSelectResults(qds,start,numberOfResults,singleRecord); + } + + /** + * Performs a SQL select using a PreparedStatement. + * Note: this method does not handle null criteria values. + * + * @param criteria + * @param con + * @return a List of Record objects. + * @throws TorqueException Error performing database query. + * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria,Connection) + */ + public static List doPSSelect(Criteria criteria, Connection con) + throws TorqueException + { + return BasePeer.doPSSelect(criteria,con); + } + + /** + * Do a Prepared Statement select according to the given criteria + * + * @param criteria + * @return a List of Record objects. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria) + */ + public static List doPSSelect(Criteria criteria) throws TorqueException + { + return BasePeer.doPSSelect(criteria); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderGetter.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderGetter.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderGetter.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderGetter.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,41 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the getMapBuilder method for the base peer class. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + * @deprecated use Torque.getMapBuilder(${mapBuilderClassName}.CLASS_NAME) instead + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return Torque.getMapBuilder( + ${mapBuilderPackage}.${mapBuilderClassName}.CLASS_NAME); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderInit.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderInit.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderInit.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderInit.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,45 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Initializes the map builder in the base peer class. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + if (Torque.isInit()) + { + try + { + Torque.getMapBuilder(${mapBuilderPackage}.${mapBuilderClassName}.CLASS_NAME); + } + catch (TorqueException e) + { + log.error("Could not initialize Peer", e); + throw new TorqueRuntimeException(e); + } + } + else + { + Torque.registerMapBuilder(${mapBuilderPackage}.${mapBuilderClassName}.CLASS_NAME); + } Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/numColumnConstant.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/numColumnConstant.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/numColumnConstant.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/numColumnConstant.vm Tue Feb 16 17:15:43 2010 @@ -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. +## +###### +## +## version $Id: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the constant which holds the number of columns in the table. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## + /** number of columns for this peer */ + public static final int numColumns = $torqueGf.getChildren("column").size(); Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObject.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObject.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObject.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObject.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,59 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the populateObject method in the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + $dbObjectClassName obj) + throws TorqueException + { + try + { +#set ( $n=0 ) +#foreach ($columnElement in $torqueGf.getChildren("column")) + #set ( $setter = $columnElement.getAttribute("setter") ) + #set ( $villageMethod = $columnElement.getAttribute("villageMethod") ) + obj.${setter}(row.getValue(offset + $n).$villageMethod); + #set ( $n = $n + 1 ) +#end + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObjects.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObjects.vm?rev=910600&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObjects.vm (added) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObjects.vm Tue Feb 16 17:15:43 2010 @@ -0,0 +1,55 @@ +## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $ +## +## Creates the populateObjects method for the base peer. +## +## This template expects the current source element to be a "table" element +## from the torque schema. +## The schema needs to be processed by the OMTransformer. +## The options and the attributes of the current source element must be set +## as velocity variables. +## + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List#if($java5 == "true")<${dbObjectClassName}>#end populateObjects(List#if($java5 == "true")#end records) + throws TorqueException + { + List#if($java5 == "true")<${dbObjectClassName}>#end results = new ArrayList#if($java5 == "true")<${dbObjectClassName}>#end(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = #if($java5 != "true")(Record)#end records.get(i); +#if ($torqueGf.getChild("inheritance-column")) + results.add(${peerClassName}.row2Object( + row, 1, ${peerClassName}.getOMClass(row, 1))); +#else + results.add(${peerClassName}.row2Object( + row, 1, ${peerClassName}.getOMClass())); +#end + } + return results; + } --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org