ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgbut...@apache.org
Subject svn commit: r833772 [7/25] - in /ibatis/java/ibator/trunk/core: ./ ibator-core/doc/ ibator-core/doc/html/ ibator-core/doc/html/configreference/ ibator-core/doc/html/generatedobjects/ ibator-core/doc/html/reference/ ibator-core/doc/html/usage/ ibator-ma...
Date Sat, 07 Nov 2009 22:59:05 GMT
Added: ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByExampleTest.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByExampleTest.java?rev=833772&view=auto
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByExampleTest.java (added)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByExampleTest.java Sat Nov  7 22:59:00 2009
@@ -0,0 +1,835 @@
+/*
+ *  Copyright 2007 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ */
+
+package ibatortest.java2.execute.conditional.java2;
+
+import ibatortest.java2.generated.conditional.java2.dao.AwfulTableDAO;
+import ibatortest.java2.generated.conditional.java2.dao.FieldsblobsDAO;
+import ibatortest.java2.generated.conditional.java2.dao.FieldsonlyDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkblobsDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkfieldsDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkfieldsblobsDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkonlyDAO;
+import ibatortest.java2.generated.conditional.java2.model.AwfulTable;
+import ibatortest.java2.generated.conditional.java2.model.AwfulTableExample;
+import ibatortest.java2.generated.conditional.java2.model.Fieldsblobs;
+import ibatortest.java2.generated.conditional.java2.model.FieldsblobsExample;
+import ibatortest.java2.generated.conditional.java2.model.FieldsblobsWithBLOBs;
+import ibatortest.java2.generated.conditional.java2.model.Fieldsonly;
+import ibatortest.java2.generated.conditional.java2.model.FieldsonlyExample;
+import ibatortest.java2.generated.conditional.java2.model.Pkblobs;
+import ibatortest.java2.generated.conditional.java2.model.PkblobsExample;
+import ibatortest.java2.generated.conditional.java2.model.Pkfields;
+import ibatortest.java2.generated.conditional.java2.model.PkfieldsExample;
+import ibatortest.java2.generated.conditional.java2.model.Pkfieldsblobs;
+import ibatortest.java2.generated.conditional.java2.model.PkfieldsblobsExample;
+import ibatortest.java2.generated.conditional.java2.model.PkonlyExample;
+import ibatortest.java2.generated.conditional.java2.model.PkonlyKey;
+
+import java.util.List;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class UpdateByExampleTest extends AbstractConditionalJava2Test {
+
+    public void testFieldsOnlyUpdateByExampleSelective() {
+        FieldsonlyDAO dao = getFieldsonlyDAO();
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(new Double(11.22));
+            record.setFloatfield(new Double(33.44));
+            record.setIntegerfield(new Integer(5));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(44.55));
+            record.setFloatfield(new Double(66.77));
+            record.setIntegerfield(new Integer(8));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(88.99));
+            record.setFloatfield(new Double(100.111));
+            record.setIntegerfield(new Integer(9));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(99));
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.createCriteria().andIntegerfieldGreaterThan(new Integer(5));
+            
+            int rows = dao.updateByExampleSelective(record, example);
+            assertEquals(2, rows);
+
+            example.clear();
+            example.createCriteria().andIntegerfieldEqualTo(new Integer(5));
+            List answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+            record = (Fieldsonly) answer.get(0);
+            assertEquals(record.getDoublefield(), new Double(11.22));
+            assertEquals(record.getFloatfield(), new Double(33.44));
+            assertEquals(record.getIntegerfield(), new Integer(5));
+            
+            example.clear();
+            example.createCriteria().andIntegerfieldEqualTo(new Integer(8));
+            answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+            record = (Fieldsonly) answer.get(0);
+            assertEquals(record.getDoublefield(), new Double(99));
+            assertEquals(record.getFloatfield(), new Double(66.77));
+            assertEquals(record.getIntegerfield(), new Integer(8));
+            
+            example.clear();
+            example.createCriteria().andIntegerfieldEqualTo(new Integer(9));
+            answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+            record = (Fieldsonly) answer.get(0);
+            assertEquals(record.getDoublefield(), new Double(99));
+            assertEquals(record.getFloatfield(), new Double(100.111));
+            assertEquals(record.getIntegerfield(), new Integer(9));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testFieldsOnlyUpdateByExample() {
+        FieldsonlyDAO dao = getFieldsonlyDAO();
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(new Double(11.22));
+            record.setFloatfield(new Double(33.44));
+            record.setIntegerfield(new Integer(5));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(44.55));
+            record.setFloatfield(new Double(66.77));
+            record.setIntegerfield(new Integer(8));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(88.99));
+            record.setFloatfield(new Double(100.111));
+            record.setIntegerfield(new Integer(9));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setIntegerfield(new Integer(22));
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.createCriteria().andIntegerfieldEqualTo(new Integer(5));
+            
+            int rows = dao.updateByExample(record, example);
+            assertEquals(1, rows);
+
+            example.clear();
+            example.createCriteria().andIntegerfieldEqualTo(new Integer(22));
+            List answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+            record = (Fieldsonly) answer.get(0);
+            assertNull(record.getDoublefield());
+            assertNull(record.getFloatfield());
+            assertEquals(record.getIntegerfield(), new Integer(22));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKOnlyUpdateByExampleSelective() {
+        PkonlyDAO dao = getPkonlyDAO();
+
+        try {
+            PkonlyKey key = new PkonlyKey();
+            key.setId(new Integer(1));
+            key.setSeqNum(new Integer(3));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(5));
+            key.setSeqNum(new Integer(6));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(7));
+            key.setSeqNum(new Integer(8));
+            dao.insert(key);
+
+            PkonlyExample example = new PkonlyExample();
+            example.createCriteria().andIdGreaterThan(new Integer(4));
+            key = new PkonlyKey();
+            key.setSeqNum(new Integer(3));
+            int rows = dao.updateByExampleSelective(key, example);
+            assertEquals(2, rows);
+
+            example.clear();
+            example.createCriteria()
+                .andIdEqualTo(new Integer(5))
+                .andSeqNumEqualTo(new Integer(3));
+            
+            rows = dao.countByExample(example);
+            assertEquals(1, rows);
+            
+            example.clear();
+            example.createCriteria()
+                .andIdEqualTo(new Integer(7))
+                .andSeqNumEqualTo(new Integer(3));
+            
+            rows = dao.countByExample(example);
+            assertEquals(1, rows);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKOnlyUpdateByExample() {
+        PkonlyDAO dao = getPkonlyDAO();
+
+        try {
+            PkonlyKey key = new PkonlyKey();
+            key.setId(new Integer(1));
+            key.setSeqNum(new Integer(3));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(5));
+            key.setSeqNum(new Integer(6));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(7));
+            key.setSeqNum(new Integer(8));
+            dao.insert(key);
+
+            PkonlyExample example = new PkonlyExample();
+            example.createCriteria()
+                .andIdEqualTo(new Integer(7));
+            key = new PkonlyKey();
+            key.setSeqNum(new Integer(3));
+            key.setId(new Integer(22));
+            int rows = dao.updateByExample(key, example);
+            assertEquals(1, rows);
+
+            example.clear();
+            example.createCriteria()
+                .andIdEqualTo(new Integer(22))
+                .andSeqNumEqualTo(new Integer(3));
+            
+            rows = dao.countByExample(example);
+            assertEquals(1, rows);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsUpdateByExampleSelective() {
+        PkfieldsDAO dao = getPkfieldsDAO();
+    
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            dao.insert(record);
+    
+            record = new Pkfields();
+            record.setFirstname("Bob");
+            record.setLastname("Jones");
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+    
+            dao.insert(record);
+
+            record = new Pkfields();
+            record.setFirstname("Fred");
+            PkfieldsExample example = new PkfieldsExample();
+            example.createCriteria().andLastnameLike("J%");
+            int rows = dao.updateByExampleSelective(record, example);
+            assertEquals(1, rows);
+            
+            example.clear();
+            example.createCriteria()
+                .andFirstnameEqualTo("Fred")
+                .andLastnameEqualTo("Jones")
+                .andId1EqualTo(new Integer(3))
+                .andId2EqualTo(new Integer(4));
+    
+            rows = dao.countByExample(example);
+            assertEquals(1, rows);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsUpdateByExample() {
+        PkfieldsDAO dao = getPkfieldsDAO();
+    
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            dao.insert(record);
+    
+            record = new Pkfields();
+            record.setFirstname("Bob");
+            record.setLastname("Jones");
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+    
+            dao.insert(record);
+
+            record = new Pkfields();
+            record.setFirstname("Fred");
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            PkfieldsExample example = new PkfieldsExample();
+            example.createCriteria()
+                .andId1EqualTo(new Integer(3))
+                .andId2EqualTo(new Integer(4));
+            
+            int rows = dao.updateByExample(record, example);
+            assertEquals(1, rows);
+            
+            example.clear();
+            example.createCriteria()
+                .andFirstnameEqualTo("Fred")
+                .andLastnameIsNull()
+                .andId1EqualTo(new Integer(3))
+                .andId2EqualTo(new Integer(4));
+    
+            rows = dao.countByExample(example);
+            assertEquals(1, rows);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKBlobsUpdateByExampleSelective() {
+        PkblobsDAO dao = getPkblobsDAO();
+    
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkblobs();
+            record.setId(new Integer(6));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkblobs newRecord = new Pkblobs();
+            newRecord.setBlob1(generateRandomBlob());
+            
+            PkblobsExample example = new PkblobsExample();
+            example.createCriteria().andIdGreaterThan(new Integer(4));
+            int rows = dao.updateByExampleSelective(newRecord, example);
+            assertEquals(1, rows);
+            
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            Pkblobs returnedRecord = (Pkblobs) answer.get(0);
+            
+            assertEquals(new Integer(6), returnedRecord.getId());
+            assertTrue(blobsAreEqual(newRecord.getBlob1(), returnedRecord.getBlob1()));
+            assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKBlobsUpdateByExampleWithoutBLOBs() {
+        PkblobsDAO dao = getPkblobsDAO();
+    
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkblobs();
+            record.setId(new Integer(6));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkblobs newRecord = new Pkblobs();
+            newRecord.setId(new Integer(8));
+            
+            PkblobsExample example = new PkblobsExample();
+            example.createCriteria().andIdGreaterThan(new Integer(4));
+            int rows = dao.updateByExampleWithoutBLOBs(newRecord, example);
+            assertEquals(1, rows);
+            
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            Pkblobs returnedRecord = (Pkblobs) answer.get(0);
+            
+            assertEquals(new Integer(8), returnedRecord.getId());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
+            assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKBlobsUpdateByExampleWithBLOBs() {
+        PkblobsDAO dao = getPkblobsDAO();
+    
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkblobs();
+            record.setId(new Integer(6));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkblobs newRecord = new Pkblobs();
+            newRecord.setId(new Integer(8));
+            
+            PkblobsExample example = new PkblobsExample();
+            example.createCriteria().andIdGreaterThan(new Integer(4));
+            int rows = dao.updateByExampleWithBLOBs(newRecord, example);
+            assertEquals(1, rows);
+            
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            Pkblobs returnedRecord = (Pkblobs) answer.get(0);
+            
+            assertEquals(new Integer(8), returnedRecord.getId());
+            assertNull(returnedRecord.getBlob1());
+            assertNull(returnedRecord.getBlob2());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsBlobsUpdateByExampleSelective() {
+        PkfieldsblobsDAO dao = getPkfieldsblobsDAO();
+    
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkfieldsblobs();
+            record.setId1(new Integer(5));
+            record.setId2(new Integer(6));
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            Pkfieldsblobs newRecord = new Pkfieldsblobs();
+            newRecord.setFirstname("Fred");
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.createCriteria().andId1NotEqualTo(new Integer(3));
+            int rows = dao.updateByExampleSelective(newRecord, example);
+            assertEquals(1, rows);
+    
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            Pkfieldsblobs returnedRecord = (Pkfieldsblobs) answer.get(0);
+            
+            assertEquals(record.getId1(), returnedRecord.getId1());
+            assertEquals(record.getId2(), returnedRecord.getId2());
+            assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
+            assertEquals(record.getLastname(), returnedRecord.getLastname());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
+            
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsBlobsUpdateByExampleWithoutBLOBs() {
+        PkfieldsblobsDAO dao = getPkfieldsblobsDAO();
+    
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkfieldsblobs();
+            record.setId1(new Integer(5));
+            record.setId2(new Integer(6));
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            Pkfieldsblobs newRecord = new Pkfieldsblobs();
+            newRecord.setId1(new Integer(5));
+            newRecord.setId2(new Integer(8));
+            newRecord.setFirstname("Fred");
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.createCriteria().andId1EqualTo(new Integer(5));
+            int rows = dao.updateByExampleWithoutBLOBs(newRecord, example);
+            assertEquals(1, rows);
+    
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            Pkfieldsblobs returnedRecord = (Pkfieldsblobs) answer.get(0);
+            
+            assertEquals(newRecord.getId1(), returnedRecord.getId1());
+            assertEquals(newRecord.getId2(), returnedRecord.getId2());
+            assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
+            assertNull(returnedRecord.getLastname());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
+            
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsBlobsUpdateByExampleWithBLOBs() {
+        PkfieldsblobsDAO dao = getPkfieldsblobsDAO();
+    
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkfieldsblobs();
+            record.setId1(new Integer(5));
+            record.setId2(new Integer(6));
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            Pkfieldsblobs newRecord = new Pkfieldsblobs();
+            newRecord.setId1(new Integer(3));
+            newRecord.setId2(new Integer(8));
+            newRecord.setFirstname("Fred");
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.createCriteria().andId1EqualTo(new Integer(3));
+            int rows = dao.updateByExampleWithBLOBs(newRecord, example);
+            assertEquals(1, rows);
+    
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            Pkfieldsblobs returnedRecord = (Pkfieldsblobs) answer.get(0);
+            
+            assertEquals(newRecord.getId1(), returnedRecord.getId1());
+            assertEquals(newRecord.getId2(), returnedRecord.getId2());
+            assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
+            assertNull(returnedRecord.getLastname());
+            assertNull(returnedRecord.getBlob1());
+            
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testFieldsBlobsUpdateByExampleSelective() {
+        FieldsblobsDAO dao = getFieldsblobsDAO();
+    
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            FieldsblobsWithBLOBs newRecord = new FieldsblobsWithBLOBs();
+            newRecord.setLastname("Doe");
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.createCriteria().andFirstnameLike("S%");
+            int rows = dao.updateByExampleSelective(newRecord, example);
+            assertEquals(1, rows);
+            
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            FieldsblobsWithBLOBs returnedRecord = (FieldsblobsWithBLOBs) answer.get(0);
+            
+            assertEquals(record.getFirstname(), returnedRecord.getFirstname());
+            assertEquals(newRecord.getLastname(), returnedRecord.getLastname());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
+            assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testFieldsBlobsUpdateByExampleWithoutBLOBs() {
+        FieldsblobsDAO dao = getFieldsblobsDAO();
+    
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            Fieldsblobs newRecord = new Fieldsblobs();
+            newRecord.setFirstname("Scott");
+            newRecord.setLastname("Doe");
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.createCriteria().andFirstnameLike("S%");
+            int rows = dao.updateByExample(newRecord, example);
+            assertEquals(1, rows);
+            
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            FieldsblobsWithBLOBs returnedRecord = (FieldsblobsWithBLOBs) answer.get(0);
+            
+            assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
+            assertEquals(newRecord.getLastname(), returnedRecord.getLastname());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
+            assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testFieldsBlobsUpdateByExampleWithBLOBs() {
+        FieldsblobsDAO dao = getFieldsblobsDAO();
+    
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            FieldsblobsWithBLOBs newRecord = new FieldsblobsWithBLOBs();
+            newRecord.setFirstname("Scott");
+            newRecord.setLastname("Doe");
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.createCriteria().andFirstnameLike("S%");
+            int rows = dao.updateByExample(newRecord, example);
+            assertEquals(1, rows);
+            
+            List answer = dao.selectByExampleWithBLOBs(example);
+            assertEquals(1, answer.size());
+            
+            FieldsblobsWithBLOBs returnedRecord = (FieldsblobsWithBLOBs) answer.get(0);
+            
+            assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
+            assertEquals(newRecord.getLastname(), returnedRecord.getLastname());
+            assertNull(returnedRecord.getBlob1());
+            assertNull(returnedRecord.getBlob2());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableUpdateByExampleSelective() {
+        AwfulTableDAO dao = getAwfulTableDAO();
+    
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            record.setId5(new Integer(5));
+            record.setId6(new Integer(6));
+            record.setId7(new Integer(7));
+            record.setSecondCustomerId(new Integer(567));
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+    
+            dao.insert(record);
+    
+            record = new AwfulTable();
+            record.seteMail("fred2@fred.com");
+            record.setEmailaddress("alsofred2@fred.com");
+            record.setFirstFirstName("fred11");
+            record.setFourthFirstName("fred44");
+            record.setFrom("from from field");
+            record.setId1(new Integer(11));
+            record.setId2(new Integer(22));
+            record.setId5(new Integer(55));
+            record.setId6(new Integer(66));
+            record.setId7(new Integer(77));
+            record.setSecondCustomerId(new Integer(567567));
+            record.setSecondFirstName("fred22");
+            record.setThirdFirstName("fred33");
+    
+            dao.insert(record);
+    
+            AwfulTable newRecord = new AwfulTable();
+            newRecord.setFirstFirstName("Alonzo");
+            AwfulTableExample example = new AwfulTableExample();
+            example.createCriteria().andEMailLike("fred2@%");
+            int rows = dao.updateByExampleSelective(newRecord, example);
+            assertEquals(1, rows);
+    
+            List answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+
+            AwfulTable returnedRecord = (AwfulTable) answer.get(0);
+            
+            assertEquals(record.getCustomerId(), returnedRecord.getCustomerId());
+            assertEquals(record.geteMail(), returnedRecord.geteMail());
+            assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
+            assertEquals(newRecord.getFirstFirstName(), returnedRecord.getFirstFirstName());
+            assertEquals(record.getFourthFirstName(), returnedRecord.getFourthFirstName());
+            assertEquals(record.getFrom(), returnedRecord.getFrom());
+            assertEquals(record.getId1(), returnedRecord.getId1());
+            assertEquals(record.getId2(), returnedRecord.getId2());
+            assertEquals(record.getId5(), returnedRecord.getId5());
+            assertEquals(record.getId6(), returnedRecord.getId6());
+            assertEquals(record.getId7(), returnedRecord.getId7());
+            assertEquals(record.getSecondCustomerId(), returnedRecord.getSecondCustomerId());
+            assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
+            assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
+            
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableUpdateByExample() {
+        AwfulTableDAO dao = getAwfulTableDAO();
+    
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            record.setId5(new Integer(5));
+            record.setId6(new Integer(6));
+            record.setId7(new Integer(7));
+            record.setSecondCustomerId(new Integer(567));
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+    
+            dao.insert(record);
+    
+            record = new AwfulTable();
+            record.seteMail("fred2@fred.com");
+            record.setEmailaddress("alsofred2@fred.com");
+            record.setFirstFirstName("fred11");
+            record.setFourthFirstName("fred44");
+            record.setFrom("from from field");
+            record.setId1(new Integer(11));
+            record.setId2(new Integer(22));
+            record.setId5(new Integer(55));
+            record.setId6(new Integer(66));
+            record.setId7(new Integer(77));
+            record.setSecondCustomerId(new Integer(567567));
+            record.setSecondFirstName("fred22");
+            record.setThirdFirstName("fred33");
+    
+            dao.insert(record);
+    
+            AwfulTable newRecord = new AwfulTable();
+            newRecord.setFirstFirstName("Alonzo");
+            newRecord.setCustomerId(new Integer(58));
+            newRecord.setId1(new Integer(111));
+            newRecord.setId2(new Integer(222));
+            newRecord.setId5(new Integer(555));
+            newRecord.setId6(new Integer(666));
+            newRecord.setId7(new Integer(777));
+            AwfulTableExample example = new AwfulTableExample();
+            example.createCriteria().andEMailLike("fred2@%");
+            int rows = dao.updateByExample(newRecord, example);
+            assertEquals(1, rows);
+
+            example.clear();
+            example.createCriteria().andCustomerIdEqualTo(new Integer(58));
+            List answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+
+            AwfulTable returnedRecord = (AwfulTable) answer.get(0);
+            
+            assertEquals(newRecord.getCustomerId(), returnedRecord.getCustomerId());
+            assertNull(returnedRecord.geteMail());
+            assertNull(returnedRecord.getEmailaddress());
+            assertEquals(newRecord.getFirstFirstName(), returnedRecord.getFirstFirstName());
+            assertNull(returnedRecord.getFourthFirstName());
+            assertNull(returnedRecord.getFrom());
+            assertEquals(newRecord.getId1(), returnedRecord.getId1());
+            assertEquals(newRecord.getId2(), returnedRecord.getId2());
+            assertEquals(newRecord.getId5(), returnedRecord.getId5());
+            assertEquals(newRecord.getId6(), returnedRecord.getId6());
+            assertEquals(newRecord.getId7(), returnedRecord.getId7());
+            assertNull(returnedRecord.getSecondCustomerId());
+            assertNull(returnedRecord.getSecondFirstName());
+            assertNull(returnedRecord.getThirdFirstName());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+}

Added: ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByPrimaryKeyTest.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByPrimaryKeyTest.java?rev=833772&view=auto
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByPrimaryKeyTest.java (added)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/conditional/java2/UpdateByPrimaryKeyTest.java Sat Nov  7 22:59:00 2009
@@ -0,0 +1,372 @@
+package ibatortest.java2.execute.conditional.java2;
+
+import ibatortest.java2.generated.conditional.java2.dao.AwfulTableDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkblobsDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkfieldsDAO;
+import ibatortest.java2.generated.conditional.java2.dao.PkfieldsblobsDAO;
+import ibatortest.java2.generated.conditional.java2.model.AwfulTable;
+import ibatortest.java2.generated.conditional.java2.model.Pkblobs;
+import ibatortest.java2.generated.conditional.java2.model.Pkfields;
+import ibatortest.java2.generated.conditional.java2.model.PkfieldsKey;
+import ibatortest.java2.generated.conditional.java2.model.Pkfieldsblobs;
+import ibatortest.java2.generated.conditional.java2.model.PkfieldsblobsKey;
+
+public class UpdateByPrimaryKeyTest extends AbstractConditionalJava2Test {
+
+    public void testPKFieldsUpdateByPrimaryKey() {
+        PkfieldsDAO dao = getPkfieldsDAO();
+    
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+    
+            dao.insert(record);
+    
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+    
+            int rows = dao.updateByPrimaryKey(record);
+            assertEquals(1, rows);
+    
+            PkfieldsKey key = new PkfieldsKey();
+            key.setId1(new Integer(1));
+            key.setId2(new Integer(2));
+    
+            Pkfields record2 = dao.selectByPrimaryKey(key);
+    
+            assertEquals(record.getFirstname(), record2.getFirstname());
+            assertEquals(record.getLastname(), record2.getLastname());
+            assertEquals(record.getId1(), record2.getId1());
+            assertEquals(record.getId2(), record2.getId2());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsUpdateByPrimaryKeySelective() {
+        PkfieldsDAO dao = getPkfieldsDAO();
+    
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setDecimal60field(new Integer(5));
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+    
+            dao.insert(record);
+    
+            Pkfields newRecord = new Pkfields();
+            newRecord.setId1(new Integer(1));
+            newRecord.setId2(new Integer(2));
+            newRecord.setFirstname("Scott");
+            newRecord.setDecimal60field(new Integer(4));
+    
+            int rows = dao.updateByPrimaryKeySelective(newRecord);
+            assertEquals(1, rows);
+    
+            PkfieldsKey key = new PkfieldsKey();
+            key.setId1(new Integer(1));
+            key.setId2(new Integer(2));
+    
+            Pkfields returnedRecord = dao.selectByPrimaryKey(key);
+    
+            assertTrue(datesAreEqual(record.getDatefield(), returnedRecord
+                    .getDatefield()));
+            assertEquals(record.getDecimal100field(), returnedRecord
+                    .getDecimal100field());
+            assertEquals(record.getDecimal155field(), returnedRecord
+                    .getDecimal155field());
+            assertEquals(record.getDecimal30field(), returnedRecord
+                    .getDecimal30field());
+            assertEquals(newRecord.getDecimal60field(), returnedRecord
+                    .getDecimal60field());
+            assertEquals(newRecord.getFirstname(), returnedRecord
+                    .getFirstname());
+            assertEquals(record.getId1(), returnedRecord.getId1());
+            assertEquals(record.getId2(), returnedRecord.getId2());
+            assertEquals(record.getLastname(), returnedRecord.getLastname());
+            assertTrue(timesAreEqual(record.getTimefield(), returnedRecord
+                    .getTimefield()));
+            assertEquals(record.getTimestampfield(), returnedRecord
+                    .getTimestampfield());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKBlobsUpdateByPrimaryKeyWithBLOBs() {
+        PkblobsDAO dao = getPkblobsDAO();
+    
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.updateByPrimaryKey(record);
+    
+            Pkblobs newRecord = dao.selectByPrimaryKey(new Integer(3));
+    
+            assertNotNull(newRecord);
+            assertEquals(record.getId(), newRecord.getId());
+            assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
+            assertTrue(blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKBlobsUpdateByPrimaryKeySelective() {
+        PkblobsDAO dao = getPkblobsDAO();
+    
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkblobs newRecord = new Pkblobs();
+            newRecord.setId(new Integer(3));
+            newRecord.setBlob2(generateRandomBlob());
+            dao.updateByPrimaryKeySelective(newRecord);
+    
+            Pkblobs returnedRecord = dao.selectByPrimaryKey(new Integer(3));
+            assertNotNull(returnedRecord);
+            assertEquals(record.getId(), returnedRecord.getId());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord
+                    .getBlob1()));
+            assertTrue(blobsAreEqual(newRecord.getBlob2(), returnedRecord
+                    .getBlob2()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsBlobsUpdateByPrimaryKeyWithBLOBs() {
+        PkfieldsblobsDAO dao = getPkfieldsblobsDAO();
+    
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkfieldsblobs updateRecord = new Pkfieldsblobs();
+            updateRecord.setId1(new Integer(3));
+            updateRecord.setId2(new Integer(4));
+            updateRecord.setFirstname("Scott");
+            updateRecord.setLastname("Jones");
+            updateRecord.setBlob1(generateRandomBlob());
+    
+            int rows = dao.updateByPrimaryKeyWithBLOBs(updateRecord);
+            assertEquals(1, rows);
+    
+            PkfieldsblobsKey key = new PkfieldsblobsKey();
+            key.setId1(new Integer(3));
+            key.setId2(new Integer(4));
+            Pkfieldsblobs newRecord = dao.selectByPrimaryKey(key);
+            assertEquals(updateRecord.getFirstname(), newRecord.getFirstname());
+            assertEquals(updateRecord.getLastname(), newRecord.getLastname());
+            assertEquals(record.getId1(), newRecord.getId1());
+            assertEquals(record.getId2(), newRecord.getId2());
+            assertTrue(blobsAreEqual(updateRecord.getBlob1(), newRecord
+                    .getBlob1()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsBlobsUpdateByPrimaryKeyWithoutBLOBs() {
+        PkfieldsblobsDAO dao = getPkfieldsblobsDAO();
+    
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkfieldsblobs updateRecord = new Pkfieldsblobs();
+            updateRecord.setId1(new Integer(3));
+            updateRecord.setId2(new Integer(4));
+            updateRecord.setFirstname("Scott");
+            updateRecord.setLastname("Jones");
+    
+            int rows = dao.updateByPrimaryKeyWithoutBLOBs(updateRecord);
+            assertEquals(1, rows);
+    
+            PkfieldsblobsKey key = new PkfieldsblobsKey();
+            key.setId1(new Integer(3));
+            key.setId2(new Integer(4));
+            Pkfieldsblobs newRecord = dao.selectByPrimaryKey(key);
+            assertEquals(updateRecord.getFirstname(), newRecord.getFirstname());
+            assertEquals(updateRecord.getLastname(), newRecord.getLastname());
+            assertEquals(record.getId1(), newRecord.getId1());
+            assertEquals(record.getId2(), newRecord.getId2());
+            assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testPKFieldsBlobsUpdateByPrimaryKeySelective() {
+        PkfieldsblobsDAO dao = getPkfieldsblobsDAO();
+    
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+    
+            Pkfieldsblobs updateRecord = new Pkfieldsblobs();
+            updateRecord.setId1(new Integer(3));
+            updateRecord.setId2(new Integer(4));
+            updateRecord.setLastname("Jones");
+    
+            int rows = dao.updateByPrimaryKeySelective(updateRecord);
+            assertEquals(1, rows);
+    
+            PkfieldsblobsKey key = new PkfieldsblobsKey();
+            key.setId1(new Integer(3));
+            key.setId2(new Integer(4));
+            Pkfieldsblobs returnedRecord = dao.selectByPrimaryKey(key);
+            assertEquals(record.getFirstname(), returnedRecord.getFirstname());
+            assertEquals(updateRecord.getLastname(), returnedRecord
+                    .getLastname());
+            assertEquals(record.getId1(), returnedRecord.getId1());
+            assertEquals(record.getId2(), returnedRecord.getId2());
+            assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord
+                    .getBlob1()));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableUpdateByPrimaryKey() {
+        AwfulTableDAO dao = getAwfulTableDAO();
+    
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            record.setId5(new Integer(5));
+            record.setId6(new Integer(6));
+            record.setId7(new Integer(7));
+            record.setSecondCustomerId(new Integer(567));
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+    
+            Integer generatedCustomerId = dao.insert(record);
+    
+            record.setId1(new Integer(11));
+            record.setId2(new Integer(22));
+    
+            int rows = dao.updateByPrimaryKey(record);
+            assertEquals(1, rows);
+    
+            AwfulTable returnedRecord = dao.selectByPrimaryKey(generatedCustomerId);
+    
+            assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
+            assertEquals(record.geteMail(), returnedRecord.geteMail());
+            assertEquals(record.getEmailaddress(), returnedRecord
+                    .getEmailaddress());
+            assertEquals(record.getFirstFirstName(), returnedRecord
+                    .getFirstFirstName());
+            assertEquals(record.getFourthFirstName(), returnedRecord
+                    .getFourthFirstName());
+            assertEquals(record.getFrom(), returnedRecord.getFrom());
+            assertEquals(record.getId1(), returnedRecord.getId1());
+            assertEquals(record.getId2(), returnedRecord.getId2());
+            assertEquals(record.getId5(), returnedRecord.getId5());
+            assertEquals(record.getId6(), returnedRecord.getId6());
+            assertEquals(record.getId7(), returnedRecord.getId7());
+            assertEquals(record.getSecondCustomerId(), returnedRecord
+                    .getSecondCustomerId());
+            assertEquals(record.getSecondFirstName(), returnedRecord
+                    .getSecondFirstName());
+            assertEquals(record.getThirdFirstName(), returnedRecord
+                    .getThirdFirstName());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableUpdateByPrimaryKeySelective() {
+        AwfulTableDAO dao = getAwfulTableDAO();
+    
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            record.setId5(new Integer(5));
+            record.setId6(new Integer(6));
+            record.setId7(new Integer(7));
+            record.setSecondCustomerId(new Integer(567));
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+    
+            Integer generatedCustomerId = dao.insert(record);
+    
+            AwfulTable newRecord = new AwfulTable();
+            newRecord.setCustomerId(generatedCustomerId);
+            newRecord.setId1(new Integer(11));
+            newRecord.setId2(new Integer(22));
+    
+            int rows = dao.updateByPrimaryKeySelective(newRecord);
+            assertEquals(1, rows);
+    
+            AwfulTable returnedRecord = dao.selectByPrimaryKey(generatedCustomerId);
+    
+            assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
+            assertEquals(record.geteMail(), returnedRecord.geteMail());
+            assertEquals(record.getEmailaddress(), returnedRecord
+                    .getEmailaddress());
+            assertEquals(record.getFirstFirstName(), returnedRecord
+                    .getFirstFirstName());
+            assertEquals(record.getFourthFirstName(), returnedRecord
+                    .getFourthFirstName());
+            assertEquals(record.getFrom(), returnedRecord.getFrom());
+            assertEquals(newRecord.getId1(), returnedRecord.getId1());
+            assertEquals(newRecord.getId2(), returnedRecord.getId2());
+            assertEquals(record.getId5(), returnedRecord.getId5());
+            assertEquals(record.getId6(), returnedRecord.getId6());
+            assertEquals(record.getId7(), returnedRecord.getId7());
+            assertEquals(record.getSecondCustomerId(), returnedRecord
+                    .getSecondCustomerId());
+            assertEquals(record.getSecondFirstName(), returnedRecord
+                    .getSecondFirstName());
+            assertEquals(record.getThirdFirstName(), returnedRecord
+                    .getThirdFirstName());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+}

Added: ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/AbstractFlatJava2Test.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/AbstractFlatJava2Test.java?rev=833772&view=auto
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/AbstractFlatJava2Test.java (added)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/AbstractFlatJava2Test.java Sat Nov  7 22:59:00 2009
@@ -0,0 +1,66 @@
+package ibatortest.java2.execute.flat.java2;
+
+import ibatortest.java2.AbstractTest;
+import ibatortest.java2.generated.flat.java2.dao.AwfulTableDAO;
+import ibatortest.java2.generated.flat.java2.dao.AwfulTableDAOImpl;
+import ibatortest.java2.generated.flat.java2.dao.FieldsblobsDAO;
+import ibatortest.java2.generated.flat.java2.dao.FieldsblobsDAOImpl;
+import ibatortest.java2.generated.flat.java2.dao.FieldsonlyDAO;
+import ibatortest.java2.generated.flat.java2.dao.FieldsonlyDAOImpl;
+import ibatortest.java2.generated.flat.java2.dao.PkblobsDAO;
+import ibatortest.java2.generated.flat.java2.dao.PkblobsDAOImpl;
+import ibatortest.java2.generated.flat.java2.dao.PkfieldsDAO;
+import ibatortest.java2.generated.flat.java2.dao.PkfieldsDAOImpl;
+import ibatortest.java2.generated.flat.java2.dao.PkfieldsblobsDAO;
+import ibatortest.java2.generated.flat.java2.dao.PkfieldsblobsDAOImpl;
+import ibatortest.java2.generated.flat.java2.dao.PkonlyDAO;
+import ibatortest.java2.generated.flat.java2.dao.PkonlyDAOImpl;
+
+public abstract class AbstractFlatJava2Test extends AbstractTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        initSqlMapClient("ibatortest/java2/execute/flat/java2/SqlMapConfig.xml", null);
+    }
+
+    protected FieldsonlyDAO getFieldsonlyDAO() {
+        FieldsonlyDAOImpl dao = new FieldsonlyDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+
+    protected PkonlyDAO getPkonlyDAO() {
+        PkonlyDAOImpl dao = new PkonlyDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+
+    protected PkfieldsDAO getPkfieldsDAO() {
+        PkfieldsDAOImpl dao = new PkfieldsDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+
+    protected PkblobsDAO getPkblobsDAO() {
+        PkblobsDAOImpl dao = new PkblobsDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+
+    protected PkfieldsblobsDAO getPkfieldsblobsDAO() {
+        PkfieldsblobsDAOImpl dao = new PkfieldsblobsDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+
+    protected FieldsblobsDAO getFieldsblobsDAO() {
+        FieldsblobsDAOImpl dao = new FieldsblobsDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+
+    protected AwfulTableDAO getAwfulTableDAO() {
+        AwfulTableDAOImpl dao = new AwfulTableDAOImpl();
+        dao.setSqlMapClient(getSqlMapClient());
+        return dao;
+    }
+}



Mime
View raw message