Return-Path: X-Original-To: apmail-db-torque-dev-archive@www.apache.org Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5C3ED9235 for ; Mon, 9 Jul 2012 13:23:37 +0000 (UTC) Received: (qmail 73016 invoked by uid 500); 9 Jul 2012 13:23:37 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 72941 invoked by uid 500); 9 Jul 2012 13:23:37 -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 72924 invoked by uid 500); 9 Jul 2012 13:23:36 -0000 Received: (qmail 72918 invoked by uid 99); 9 Jul 2012 13:23:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jul 2012 13:23:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Mon, 09 Jul 2012 13:23:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0D7EB238889B; Mon, 9 Jul 2012 13:23:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1359157 - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/util/ torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/ torque-templates/src/main/resources/org/apache/torque/templ... Date: Mon, 09 Jul 2012 13:23:14 -0000 To: torque-commits@db.apache.org From: tfischer@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120709132315.0D7EB238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tfischer Date: Mon Jul 9 13:23:14 2012 New Revision: 1359157 URL: http://svn.apache.org/viewvc?rev=1359157&view=rev Log: Fix bugs for BooleanInts including test cases - saving data objects containing "true" values results in "false" values in the database - correctBooleans is also used for inserts (allowing both native/boolean insert values) Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doInsert.vm db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java?rev=1359157&r1=1359156&r2=1359157&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java Mon Jul 9 13:23:14 2012 @@ -2314,17 +2314,33 @@ public class BasePeerImpl implements Ser JdbcTypedValue columnValue = entry.getValue(); if ("BOOLEANINT".equals(column.getTorqueType())) { - columnValue.setValue( - Boolean.TRUE.equals(columnValue.getValue()) - ? Integer.valueOf(1) - : Integer.valueOf(0)); + if (Boolean.TRUE.equals(columnValue.getValue())) + { + entry.setValue(new JdbcTypedValue(1, Types.INTEGER)); + } + else if (Boolean.FALSE.equals(columnValue.getValue())) + { + entry.setValue(new JdbcTypedValue(0, Types.INTEGER)); + } + else if (columnValue.getValue() == null) + { + entry.setValue(new JdbcTypedValue(null, Types.INTEGER)); + } } else if ("BOOLEANCHAR".equals(column.getTorqueType())) { - columnValue.setValue( - Boolean.TRUE.equals(columnValue.getValue()) - ? "Y" - : "N"); + if (Boolean.TRUE.equals(columnValue.getValue())) + { + entry.setValue(new JdbcTypedValue("Y", Types.CHAR)); + } + else if (Boolean.FALSE.equals(columnValue.getValue())) + { + entry.setValue(new JdbcTypedValue("N", Types.CHAR)); + } + else if (columnValue.getValue() == null) + { + entry.setValue(new JdbcTypedValue(null, Types.CHAR)); + } } } } Modified: 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=1359157&r1=1359156&r2=1359157&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm Mon Jul 9 13:23:14 2012 @@ -28,12 +28,54 @@ ## as velocity variables. ## /** + * Method to do inserts. + * + * @param columnValues the values to insert. + * +#if ($torqueGen.getChild("primary-keys").getChildren("column").isEmpty()) + * @return always null (because the table does not have a primary key). +#else + * @return the primary key of the inserted row. +#end + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(ColumnValues columnValues) + throws TorqueException + { + return ${peerImplGetter}().doInsert(columnValues); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. + * + * @param columnValues the values to insert. + * @param con the connection to use, not null. + * +#if ($torqueGen.getChild("primary-keys").getChildren("column").isEmpty()) + * @return always null (because the table does not have a primary key). +#else + * @return the primary key of the inserted row. +#end + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(ColumnValues columnValues, Connection con) + throws TorqueException + { + return ${peerImplGetter}().doInsert(columnValues, 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 + public static void doInsert($dbObjectClassName obj) + throws TorqueException { ${peerImplGetter}().doInsert(obj); } @@ -49,7 +91,7 @@ * rethrown wrapped into a TorqueException. */ public static void doInsert($dbObjectClassName obj, Connection con) - throws TorqueException + throws TorqueException { ${peerImplGetter}().doInsert(obj, con); } Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/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/impl/base/doInsert.vm?rev=1359157&r1=1359156&r2=1359157&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doInsert.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doInsert.vm Mon Jul 9 13:23:14 2012 @@ -28,6 +28,64 @@ ## as velocity variables. ## /** + * Method to do inserts. + * + * @param columnValues the values to insert. + * +#if ($torqueGen.getChild("primary-keys").getChildren("column").isEmpty()) + * @return always null (because the table does not have a primary key). +#else + * @return the primary key of the inserted row. +#end + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public ObjectKey doInsert(ColumnValues columnValues) throws TorqueException + { + Connection connection = null; + try + { + connection = Transaction.begin( + ${peerClassName}.DATABASE_NAME); + ObjectKey result = doInsert(columnValues, connection); + Transaction.commit(connection); + connection = null; + return result; + } + finally + { + if (connection != null) + { + Transaction.safeRollback(connection); + } + } + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. + * + * @param columnValues the values to insert. + * @param con the connection to use, not null. + * +#if ($torqueGen.getChild("primary-keys").getChildren("column").isEmpty()) + * @return always null (because the table does not have a primary key). +#else + * @return the primary key of the inserted row. +#end + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public ObjectKey doInsert(ColumnValues columnValues, Connection con) + throws TorqueException + { + correctBooleans(columnValues); + return super.doInsert(columnValues, con); + } + + /** * Method to do inserts * * @throws TorqueException Any exceptions caught during processing will be Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java?rev=1359157&r1=1359156&r2=1359157&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java Mon Jul 9 13:23:14 2012 @@ -1,5 +1,6 @@ package org.apache.torque.datatypes; +import java.sql.Types; import java.util.List; import org.apache.torque.BaseDatabaseTestCase; @@ -11,6 +12,8 @@ import org.apache.torque.om.StringKey; import org.apache.torque.test.BintBcharValue; import org.apache.torque.test.BintBcharValuePeer; import org.apache.torque.util.BasePeer; +import org.apache.torque.util.ColumnValues; +import org.apache.torque.util.JdbcTypedValue; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -48,8 +51,8 @@ public class BooleanIntCharTest extends BintBcharValue bc = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); - assertEquals(Boolean.TRUE, (Boolean) bc.getBintValue()); - assertEquals(Boolean.TRUE, (Boolean) bc.getBcharValue()); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); assertEquals(Boolean.TRUE, bc.getBintObjectValue()); assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); } @@ -65,8 +68,8 @@ public class BooleanIntCharTest extends BintBcharValue bc = BintBcharValuePeer.retrieveByPK(new StringKey("f1")); - assertEquals(Boolean.FALSE, (Boolean) bc.getBintValue()); - assertEquals(Boolean.FALSE, (Boolean) bc.getBcharValue()); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); assertEquals(Boolean.FALSE, bc.getBintObjectValue()); assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); } @@ -87,6 +90,160 @@ public class BooleanIntCharTest extends } /** + * Checks whether we can insert boolean true values. + * + * @throws Exception if the test fails + */ + public void testInsertBooleanIntCharTrueValue() throws Exception + { + // prepare + fillTables(); + BintBcharValue bc = new BintBcharValue(); + bc.setPrimaryKey("new"); + bc.setBintValue(true); + bc.setBcharValue(true); + bc.setBintObjectValue(Boolean.TRUE); + bc.setBcharObjectValue(Boolean.TRUE); + + // execute + bc.save(); + + // verify + bc = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); + assertEquals(Boolean.TRUE, bc.getBintObjectValue()); + assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can insert boolean false values. + * + * @throws Exception if the test fails + */ + public void testInsertBooleanIntCharFalseValue() throws Exception + { + // prepare + fillTables(); + BintBcharValue bc = new BintBcharValue(); + bc.setPrimaryKey("new"); + bc.setBintValue(false); + bc.setBcharValue(false); + bc.setBintObjectValue(Boolean.FALSE); + bc.setBcharObjectValue(Boolean.FALSE); + + // execute + bc.save(); + + // verify + bc = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); + assertEquals(Boolean.FALSE, bc.getBintObjectValue()); + assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can insert Boolean null values. + * + * @throws Exception if the test fails + */ + public void testInserteBooleanIntCharNullValue() throws Exception + { + // prepare + fillTables(); + BintBcharValue bc = new BintBcharValue(); + bc.setPrimaryKey("new"); + bc.setBintObjectValue(null); + bc.setBcharObjectValue(null); + + // execute + bc.save(); + + // verify + bc = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(null, bc.getBintObjectValue()); + assertEquals(null, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can update values to boolean true. + * + * @throws Exception if the test fails + */ + public void testUpdateBooleanIntCharTrueValue() throws Exception + { + // prepare + fillTables(); + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("f1")); + bc.setBintValue(true); + bc.setBcharValue(true); + bc.setBintObjectValue(Boolean.TRUE); + bc.setBcharObjectValue(Boolean.TRUE); + + // execute + bc.save(); + + // verify + bc = BintBcharValuePeer.retrieveByPK(new StringKey("f1")); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); + assertEquals(Boolean.TRUE, bc.getBintObjectValue()); + assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can update values to boolean false. + * + * @throws Exception if the test fails + */ + public void testWriteBooleanIntCharFalseValue() throws Exception + { + // prepare + fillTables(); + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + bc.setBintValue(false); + bc.setBcharValue(false); + bc.setBintObjectValue(Boolean.FALSE); + bc.setBcharObjectValue(Boolean.FALSE); + + // execute + bc.save(); + + // verify + bc = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); + assertEquals(Boolean.FALSE, bc.getBintObjectValue()); + assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can update values to Boolean null. + * + * @throws Exception if the test fails + */ + public void testUpdateBooleanIntCharNullValue() throws Exception + { + // prepare + fillTables(); + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + bc.setBintObjectValue(null); + bc.setBcharObjectValue(null); + + // execute + bc.save(); + + // verify + bc = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + assertEquals(null, bc.getBintObjectValue()); + assertEquals(null, bc.getBcharObjectValue()); + } + + /** * Check whether we can impose the condition Boolean True to * booleanint/booleanchar columns. * @@ -330,6 +487,460 @@ public class BooleanIntCharTest extends } /** + * Checks whether we can pass boolean true values to doInsert. + * + * @throws Exception if the test fails + */ + public void testDoInsertBooleanTrueValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("new", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + + // execute + BintBcharValuePeer.doInsert(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); + assertEquals(Boolean.TRUE, bc.getBintObjectValue()); + assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass native true values to doInsert. + * + * @throws Exception if the test fails + */ + public void testDoInsertNativeTrueValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("new", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(1, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue("Y", Types.CHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(1, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue("Y", Types.CHAR)); + + // execute + BintBcharValuePeer.doInsert(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); + assertEquals(Boolean.TRUE, bc.getBintObjectValue()); + assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass boolean false values to doInsert. + * + * @throws Exception if the test fails + */ + public void testDoInsertBooleanFalseValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("new", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + + // execute + BintBcharValuePeer.doInsert(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); + assertEquals(Boolean.FALSE, bc.getBintObjectValue()); + assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass native false values to doInsert. + * + * @throws Exception if the test fails + */ + public void testDoInsertNativeFalseValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("new", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(0, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue("N", Types.CHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(0, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue("N", Types.CHAR)); + + // execute + BintBcharValuePeer.doInsert(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); + assertEquals(Boolean.FALSE, bc.getBintObjectValue()); + assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass Boolean null values to doInsert. + * + * @throws Exception if the test fails + */ + public void testDoInsertBooleanNullValue() throws Exception + { + // prepare + fillTables(); + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("new", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(1, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue("Y", Types.BIT)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(null, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(null, Types.BIT)); + + // execute + BintBcharValuePeer.doInsert(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(null, bc.getBintObjectValue()); + assertEquals(null, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass native null values to doInsert. + * + * @throws Exception if the test fails + */ + public void testDoInsertNativeNullValue() throws Exception + { + // prepare + fillTables(); + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("new", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(0, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue("N", Types.CHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(null, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(null, Types.CHAR)); + + // execute + BintBcharValuePeer.doInsert(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("new")); + assertEquals(null, bc.getBintObjectValue()); + assertEquals(null, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass boolean true values to doUpdate. + * + * @throws Exception if the test fails + */ + public void testDoUpdateBooleanTrueValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("f1", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(Boolean.TRUE, Types.BIT)); + + // execute + BintBcharValuePeer.doUpdate(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("f1")); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); + assertEquals(Boolean.TRUE, bc.getBintObjectValue()); + assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass native true values to doUpdate. + * + * @throws Exception if the test fails + */ + public void testDoUpdateNativeTrueValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("f1", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(1, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue("Y", Types.CHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(1, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue("Y", Types.CHAR)); + + // execute + BintBcharValuePeer.doUpdate(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("f1")); + assertEquals(true, bc.getBintValue()); + assertEquals(true, bc.getBcharValue()); + assertEquals(Boolean.TRUE, bc.getBintObjectValue()); + assertEquals(Boolean.TRUE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass boolean false values to doUpdate. + * + * @throws Exception if the test fails + */ + public void testDoUpdateBooleanFalseValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("t1", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(Boolean.FALSE, Types.BIT)); + + // execute + BintBcharValuePeer.doUpdate(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); + assertEquals(Boolean.FALSE, bc.getBintObjectValue()); + assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass native false values to doUpdate. + * + * @throws Exception if the test fails + */ + public void testDoUpdateNativeFalseValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("t1", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_VALUE, + new JdbcTypedValue(0, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_VALUE, + new JdbcTypedValue("N", Types.CHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(0, Types.INTEGER)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue("N", Types.CHAR)); + + // execute + BintBcharValuePeer.doUpdate(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + assertEquals(false, bc.getBintValue()); + assertEquals(false, bc.getBcharValue()); + assertEquals(Boolean.FALSE, bc.getBintObjectValue()); + assertEquals(Boolean.FALSE, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass Boolean null values to doUpdate. + * + * @throws Exception if the test fails + */ + public void testDoUpdateBooleanNullValue() throws Exception + { + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("t1", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(null, Types.BIT)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(null, Types.BIT)); + + // execute + BintBcharValuePeer.doUpdate(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + assertEquals(null, bc.getBintObjectValue()); + assertEquals(null, bc.getBcharObjectValue()); + } + + /** + * Checks whether we can pass native null values to doUpdate. + * + * @throws Exception if the test fails + */ + public void testDoUpdateNativeNullValue() throws Exception + { + // prepare + fillTables(); + // prepare + fillTables(); + ColumnValues columnValues + = new ColumnValues(BintBcharValuePeer.getTableMap()); + columnValues.put( + BintBcharValuePeer.ID, + new JdbcTypedValue("t1", Types.VARCHAR)); + columnValues.put( + BintBcharValuePeer.BINT_OBJECT_VALUE, + new JdbcTypedValue(null, Types.NUMERIC)); + columnValues.put( + BintBcharValuePeer.BCHAR_OBJECT_VALUE, + new JdbcTypedValue(null, Types.CHAR)); + + // execute + BintBcharValuePeer.doUpdate(columnValues); + + // verify + BintBcharValue bc + = BintBcharValuePeer.retrieveByPK(new StringKey("t1")); + assertEquals(null, bc.getBintObjectValue()); + assertEquals(null, bc.getBcharObjectValue()); + } + + /** * Delete all previous data from the tested tables * and re-inserts test data. */ --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org