Source Code Cross Referenced for TestUpdateMckoi.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » database » queries » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.database.queries 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003:         * Distributed under the terms of either:
0004:         * - the common development and distribution license (CDDL), v1.0; or
0005:         * - the GNU Lesser General Public License, v2.1 or later
0006:         * $Id: TestUpdateMckoi.java 3695 2007-03-16 09:26:50Z gbevin $
0007:         */
0008:        package com.uwyn.rife.database.queries;
0009:
0010:        import com.uwyn.rife.database.BeanImpl;
0011:        import com.uwyn.rife.database.BeanImplConstrained;
0012:        import com.uwyn.rife.database.DbPreparedStatement;
0013:        import com.uwyn.rife.database.DbPreparedStatementHandler;
0014:        import com.uwyn.rife.database.exceptions.FieldsRequiredException;
0015:        import com.uwyn.rife.database.exceptions.TableNameRequiredException;
0016:        import com.uwyn.rife.database.exceptions.UnsupportedSqlFeatureException;
0017:        import com.uwyn.rife.database.types.SqlNull;
0018:        import java.math.BigDecimal;
0019:        import java.sql.Time;
0020:        import java.sql.Timestamp;
0021:        import java.util.Arrays;
0022:        import java.util.Calendar;
0023:
0024:        public class TestUpdateMckoi extends TestUpdate {
0025:            public TestUpdateMckoi(String name) {
0026:                super (name);
0027:            }
0028:
0029:            public void testInstantiationMckoi() {
0030:                Update query = new Update(mMckoi);
0031:                assertNotNull(query);
0032:                try {
0033:                    query.getSql();
0034:                    fail();
0035:                } catch (TableNameRequiredException e) {
0036:                    assertEquals(e.getQueryName(), "Update");
0037:                }
0038:            }
0039:
0040:            public void testIncompleteQueryMckoi() {
0041:                Update query = new Update(mMckoi);
0042:                try {
0043:                    query.getSql();
0044:                    fail();
0045:                } catch (TableNameRequiredException e) {
0046:                    assertEquals(e.getQueryName(), "Update");
0047:                }
0048:                query.table("tablename4");
0049:                try {
0050:                    query.getSql();
0051:                    fail();
0052:                } catch (FieldsRequiredException e) {
0053:                    assertEquals(e.getQueryName(), "Update");
0054:                }
0055:                query.field("col1", "val1");
0056:                assertNotNull(query.getSql());
0057:            }
0058:
0059:            public void testClearMckoi() {
0060:                Update query = new Update(mMckoi);
0061:                query.table("tablename4").field("col1", "val1");
0062:                assertNotNull(query.getSql());
0063:                query.clear();
0064:                try {
0065:                    query.getSql();
0066:                    fail();
0067:                } catch (TableNameRequiredException e) {
0068:                    assertEquals(e.getQueryName(), "Update");
0069:                }
0070:            }
0071:
0072:            public void testHintMckoi() {
0073:                Update query = new Update(mMckoi).hint("NO_INDEX").table(
0074:                        "tablename").field("propertyByte", (byte) 16);
0075:                try {
0076:                    query.getSql();
0077:                    fail();
0078:                } catch (UnsupportedSqlFeatureException e) {
0079:                    assertTrue(true);
0080:                }
0081:            }
0082:
0083:            public void testFieldMckoi() {
0084:                Calendar cal = Calendar.getInstance();
0085:                cal.set(2002, 7, 19, 12, 17, 52);
0086:                cal.set(Calendar.MILLISECOND, 462);
0087:                Update query = new Update(mMckoi);
0088:                query.table("tablename").where("propertyByte = 89").field(
0089:                        "nullColumn", SqlNull.NULL).field("propertyBigDecimal",
0090:                        new BigDecimal("98347.876438637")).field(
0091:                        "propertyBoolean", true).field("propertyByte",
0092:                        (byte) 16).field("propertyCalendar", cal.getTime())
0093:                        .field("propertyChar", 'M').field("propertyDate", cal)
0094:                        .field("propertyDouble", 12.3d).field("propertyFloat",
0095:                                13.4f).field("propertyInt", 34).field(
0096:                                "propertyLong", 45L).field("propertyShort",
0097:                                (short) 12).field("propertySqlDate",
0098:                                new java.sql.Date(cal.getTime().getTime()))
0099:                        .field("propertyString", "string'value").field(
0100:                                "propertyStringbuffer",
0101:                                new StringBuffer("stringbuffer'value")).field(
0102:                                "propertyTime",
0103:                                new Time(cal.getTime().getTime())).field(
0104:                                "propertyTimestamp",
0105:                                new Timestamp(cal.getTime().getTime()));
0106:                assertEquals(
0107:                        query.getSql(),
0108:                        "UPDATE tablename SET nullColumn = NULL, propertyBigDecimal = 98347.876438637, propertyBoolean = true, propertyByte = 16, propertyCalendar = TIMESTAMP '2002-08-19 12:17:52.462', propertyChar = 'M', propertyDate = TIMESTAMP '2002-08-19 12:17:52.462', propertyDouble = 12.3, propertyFloat = 13.4, propertyInt = 34, propertyLong = 45, propertyShort = 12, propertySqlDate = DATE '2002-08-19', propertyString = 'string''value', propertyStringbuffer = 'stringbuffer''value', propertyTime = TIME '12:17:52', propertyTimestamp = TIMESTAMP '2002-08-19 12:17:52.462' WHERE propertyByte = 89");
0109:                assertTrue(execute(query));
0110:            }
0111:
0112:            public void testFieldCustomMckoi() {
0113:                Update query = new Update(mMckoi);
0114:                query.table("tablename").fieldCustom("propertyInt",
0115:                        "TONUMBER(DATEOB('Aug 1, 2000'))");
0116:                assertEquals(query.getSql(),
0117:                        "UPDATE tablename SET propertyInt = TONUMBER(DATEOB('Aug 1, 2000'))");
0118:                assertTrue(execute(query));
0119:            }
0120:
0121:            public void testFieldParametersMckoi() {
0122:                Update query = new Update(mMckoi);
0123:                query.table("tablename");
0124:
0125:                assertNull(query.getParameters());
0126:
0127:                query.fieldParameter("nullColumn").fieldParameter(
0128:                        "propertyBigDecimal").fieldParameter("propertyBoolean")
0129:                        .fieldParameter("propertyByte").fieldParameter(
0130:                                "propertyCalendar").fieldParameter(
0131:                                "propertyChar").fieldParameter("propertyDate")
0132:                        .fieldParameter("propertyDouble").fieldParameter(
0133:                                "propertyFloat").fieldParameter("propertyInt")
0134:                        .fieldParameter("propertyLong").fieldParameter(
0135:                                "propertyShort").fieldParameter(
0136:                                "propertySqlDate").fieldParameter(
0137:                                "propertyString").fieldParameter(
0138:                                "propertyStringbuffer").fieldParameter(
0139:                                "propertyTime").fieldParameter(
0140:                                "propertyTimestamp");
0141:
0142:                assertEquals(query.getParameters().getOrderedNames().size(), 17);
0143:                assertEquals(query.getParameters().getOrderedNames().get(0),
0144:                        "nullColumn");
0145:                assertEquals(query.getParameters().getOrderedNames().get(1),
0146:                        "propertyBigDecimal");
0147:                assertEquals(query.getParameters().getOrderedNames().get(2),
0148:                        "propertyBoolean");
0149:                assertEquals(query.getParameters().getOrderedNames().get(3),
0150:                        "propertyByte");
0151:                assertEquals(query.getParameters().getOrderedNames().get(4),
0152:                        "propertyCalendar");
0153:                assertEquals(query.getParameters().getOrderedNames().get(5),
0154:                        "propertyChar");
0155:                assertEquals(query.getParameters().getOrderedNames().get(6),
0156:                        "propertyDate");
0157:                assertEquals(query.getParameters().getOrderedNames().get(7),
0158:                        "propertyDouble");
0159:                assertEquals(query.getParameters().getOrderedNames().get(8),
0160:                        "propertyFloat");
0161:                assertEquals(query.getParameters().getOrderedNames().get(9),
0162:                        "propertyInt");
0163:                assertEquals(query.getParameters().getOrderedNames().get(10),
0164:                        "propertyLong");
0165:                assertEquals(query.getParameters().getOrderedNames().get(11),
0166:                        "propertyShort");
0167:                assertEquals(query.getParameters().getOrderedNames().get(12),
0168:                        "propertySqlDate");
0169:                assertEquals(query.getParameters().getOrderedNames().get(13),
0170:                        "propertyString");
0171:                assertEquals(query.getParameters().getOrderedNames().get(14),
0172:                        "propertyStringbuffer");
0173:                assertEquals(query.getParameters().getOrderedNames().get(15),
0174:                        "propertyTime");
0175:                assertEquals(query.getParameters().getOrderedNames().get(16),
0176:                        "propertyTimestamp");
0177:                assertTrue(Arrays.equals(query.getParameters()
0178:                        .getOrderedNamesArray(), new String[] { "nullColumn",
0179:                        "propertyBigDecimal", "propertyBoolean",
0180:                        "propertyByte", "propertyCalendar", "propertyChar",
0181:                        "propertyDate", "propertyDouble", "propertyFloat",
0182:                        "propertyInt", "propertyLong", "propertyShort",
0183:                        "propertySqlDate", "propertyString",
0184:                        "propertyStringbuffer", "propertyTime",
0185:                        "propertyTimestamp" }));
0186:
0187:                assertEquals(
0188:                        query.getSql(),
0189:                        "UPDATE tablename SET nullColumn = ?, propertyBigDecimal = ?, propertyBoolean = ?, propertyByte = ?, propertyCalendar = ?, propertyChar = ?, propertyDate = ?, propertyDouble = ?, propertyFloat = ?, propertyInt = ?, propertyLong = ?, propertyShort = ?, propertySqlDate = ?, propertyString = ?, propertyStringbuffer = ?, propertyTime = ?, propertyTimestamp = ?");
0190:
0191:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0192:                    public void setParameters(DbPreparedStatement statement) {
0193:                        Calendar cal = Calendar.getInstance();
0194:                        cal.set(2002, 7, 19, 12, 17, 52);
0195:                        cal.set(Calendar.MILLISECOND, 462);
0196:                        statement.setString(1, null).setBigDecimal(2,
0197:                                new BigDecimal("98347.876438637")).setBoolean(
0198:                                3, true).setByte(4, (byte) 16).setDate(5,
0199:                                new java.sql.Date(cal.getTime().getTime()))
0200:                                .setString(6, "M").setDate(
0201:                                        7,
0202:                                        new java.sql.Date(cal.getTime()
0203:                                                .getTime()))
0204:                                .setDouble(8, 12.3d).setFloat(9, 13.4f).setInt(
0205:                                        10, 34).setLong(11, 45L).setShort(12,
0206:                                        (short) 12).setDate(
0207:                                        13,
0208:                                        new java.sql.Date(cal.getTime()
0209:                                                .getTime())).setString(14,
0210:                                        "string'value").setString(15,
0211:                                        "string'value2").setTime(16,
0212:                                        new Time(cal.getTime().getTime()))
0213:                                .setTimestamp(17,
0214:                                        new Timestamp(cal.getTime().getTime()));
0215:                    }
0216:                }));
0217:            }
0218:
0219:            public void testFieldParametersMixedMckoi() {
0220:                Update query = new Update(mMckoi);
0221:                query.table("tablename");
0222:
0223:                assertNull(query.getParameters());
0224:
0225:                final Calendar cal = Calendar.getInstance();
0226:                cal.set(2002, 7, 19, 12, 17, 52);
0227:                cal.set(Calendar.MILLISECOND, 462);
0228:                query.fieldParameter("nullColumn").field("propertyBigDecimal",
0229:                        new BigDecimal("98347.876438637")).fieldParameter(
0230:                        "propertyBoolean").fieldParameter("propertyByte")
0231:                        .field("propertyCalendar", cal.getTime())
0232:                        .fieldParameter("propertyChar").field("propertyDate",
0233:                                cal).field("propertyDouble", 12.3d)
0234:                        .fieldParameter("propertyFloat").fieldParameter(
0235:                                "propertyInt").field("propertyLong", 45L)
0236:                        .field("propertyShort", (short) 12).fieldParameter(
0237:                                "propertySqlDate").fieldParameter(
0238:                                "propertyString").field("propertyStringbuffer",
0239:                                new StringBuffer("stringbuffer'value")).field(
0240:                                "propertyTime",
0241:                                new Time(cal.getTime().getTime()))
0242:                        .fieldParameter("propertyTimestamp");
0243:
0244:                assertEquals(query.getParameters().getOrderedNames().size(), 9);
0245:                assertEquals(query.getParameters().getOrderedNames().get(0),
0246:                        "nullColumn");
0247:                assertEquals(query.getParameters().getOrderedNames().get(1),
0248:                        "propertyBoolean");
0249:                assertEquals(query.getParameters().getOrderedNames().get(2),
0250:                        "propertyByte");
0251:                assertEquals(query.getParameters().getOrderedNames().get(3),
0252:                        "propertyChar");
0253:                assertEquals(query.getParameters().getOrderedNames().get(4),
0254:                        "propertyFloat");
0255:                assertEquals(query.getParameters().getOrderedNames().get(5),
0256:                        "propertyInt");
0257:                assertEquals(query.getParameters().getOrderedNames().get(6),
0258:                        "propertySqlDate");
0259:                assertEquals(query.getParameters().getOrderedNames().get(7),
0260:                        "propertyString");
0261:                assertEquals(query.getParameters().getOrderedNames().get(8),
0262:                        "propertyTimestamp");
0263:                assertTrue(Arrays.equals(query.getParameters()
0264:                        .getOrderedNamesArray(), new String[] { "nullColumn",
0265:                        "propertyBoolean", "propertyByte", "propertyChar",
0266:                        "propertyFloat", "propertyInt", "propertySqlDate",
0267:                        "propertyString", "propertyTimestamp" }));
0268:
0269:                assertEquals(
0270:                        query.getSql(),
0271:                        "UPDATE tablename SET nullColumn = ?, propertyBigDecimal = 98347.876438637, propertyBoolean = ?, propertyByte = ?, propertyCalendar = TIMESTAMP '2002-08-19 12:17:52.462', propertyChar = ?, propertyDate = TIMESTAMP '2002-08-19 12:17:52.462', propertyDouble = 12.3, propertyFloat = ?, propertyInt = ?, propertyLong = 45, propertyShort = 12, propertySqlDate = ?, propertyString = ?, propertyStringbuffer = 'stringbuffer''value', propertyTime = TIME '12:17:52', propertyTimestamp = ?");
0272:
0273:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0274:                    public void setParameters(DbPreparedStatement statement) {
0275:                        statement.setString(1, null).setBoolean(2, true)
0276:                                .setByte(3, (byte) 16).setString(4, "M")
0277:                                .setFloat(5, 13.4f).setInt(6, 34).setDate(
0278:                                        7,
0279:                                        new java.sql.Date(cal.getTime()
0280:                                                .getTime())).setString(8,
0281:                                        "string'value").setTimestamp(9,
0282:                                        new Timestamp(cal.getTime().getTime()));
0283:                    }
0284:                }));
0285:            }
0286:
0287:            public void testFieldsMckoi() {
0288:                Calendar cal = Calendar.getInstance();
0289:                cal.set(2002, 7, 19, 12, 17, 52);
0290:                cal.set(Calendar.MILLISECOND, 462);
0291:                Update query = new Update(mMckoi);
0292:                query.table("tablename").where("propertyByte = 89").fields(
0293:                        new Object[] { "nullColumn", SqlNull.NULL,
0294:                                "propertyBigDecimal",
0295:                                new BigDecimal("98347.876438637"),
0296:                                "propertyBoolean", new Boolean(true),
0297:                                "propertyByte", new Byte((byte) 16),
0298:                                "propertyCalendar", cal.getTime(),
0299:                                "propertyChar", new Character('M'),
0300:                                "propertyDate", cal, "propertyDouble",
0301:                                new Double(12.3d), "propertyFloat",
0302:                                new Float(13.4f), "propertyInt",
0303:                                new Integer(34), "propertyLong", new Long(45L),
0304:                                "propertyShort", new Short((short) 12),
0305:                                "propertySqlDate",
0306:                                new java.sql.Date(cal.getTime().getTime()),
0307:                                "propertyString", new String("string'value"),
0308:                                "propertyStringbuffer",
0309:                                new StringBuffer("stringbuffer'value"),
0310:                                "propertyTime",
0311:                                new Time(cal.getTime().getTime()),
0312:                                "propertyTimestamp",
0313:                                new Timestamp(cal.getTime().getTime()) });
0314:                assertEquals(
0315:                        query.getSql(),
0316:                        "UPDATE tablename SET nullColumn = NULL, propertyBigDecimal = 98347.876438637, propertyBoolean = true, propertyByte = 16, propertyCalendar = TIMESTAMP '2002-08-19 12:17:52.462', propertyChar = 'M', propertyDate = TIMESTAMP '2002-08-19 12:17:52.462', propertyDouble = 12.3, propertyFloat = 13.4, propertyInt = 34, propertyLong = 45, propertyShort = 12, propertySqlDate = DATE '2002-08-19', propertyString = 'string''value', propertyStringbuffer = 'stringbuffer''value', propertyTime = TIME '12:17:52', propertyTimestamp = TIMESTAMP '2002-08-19 12:17:52.462' WHERE propertyByte = 89");
0317:                assertTrue(execute(query));
0318:            }
0319:
0320:            public void testWhereConstructionMckoi() {
0321:                Update query = new Update(mMckoi);
0322:                query.table("tablename").field("propertyBoolean", true).field(
0323:                        "propertyByte", (byte) 16).where("propertyInt = 545")
0324:                        .whereAnd("propertyLong < 50000").whereOr(
0325:                                "propertyChar = 'v'");
0326:                assertEquals(
0327:                        query.getSql(),
0328:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyInt = 545 AND propertyLong < 50000 OR propertyChar = 'v'");
0329:                assertTrue(execute(query));
0330:            }
0331:
0332:            public void testWhereConstructionGroupMckoi() {
0333:                Update query = new Update(mMckoi);
0334:                query.table("tablename").field("propertyBoolean", true).field(
0335:                        "propertyByte", (byte) 16).where("propertyInt = 545")
0336:                        .whereAnd("propertyLong < 50000").startWhereOr()
0337:                        .whereParameter("propertyString", "=").whereAnd(
0338:                                "propertyByte", "<=", (byte) 0).startWhereAnd()
0339:                        .where("propertyBoolean", "!=", true).whereParameterOr(
0340:                                "propertyStringbuffer", "LIKE").end().end()
0341:                        .whereOr("propertyChar = 'v'");
0342:
0343:                assertEquals(query.getParameters().getOrderedNames().get(0),
0344:                        "propertyString");
0345:                assertEquals(query.getParameters().getOrderedNames().get(1),
0346:                        "propertyStringbuffer");
0347:                assertTrue(Arrays.equals(query.getParameters()
0348:                        .getOrderedNamesArray(), new String[] {
0349:                        "propertyString", "propertyStringbuffer" }));
0350:
0351:                assertEquals(
0352:                        query.getSql(),
0353:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyInt = 545 AND propertyLong < 50000 OR (propertyString = ? AND propertyByte <= 0 AND (propertyBoolean != true OR propertyStringbuffer LIKE ?)) OR propertyChar = 'v'");
0354:
0355:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0356:                    public void setParameters(DbPreparedStatement statement) {
0357:                        statement
0358:                                .setString("propertyString", "someotherstring")
0359:                                .setString("propertyStringbuffer", "stringbuff");
0360:                    }
0361:                }));
0362:            }
0363:
0364:            public void testWhereTypedMckoi() {
0365:                Update query = new Update(mMckoi);
0366:                query.table("tablename").field("propertyBoolean", true).field(
0367:                        "propertyByte", (byte) 16);
0368:
0369:                Calendar cal = Calendar.getInstance();
0370:                cal.set(2003, 2, 3, 10, 1, 28);
0371:                cal.set(Calendar.MILLISECOND, 154);
0372:
0373:                query.where("propertyBigDecimal", ">=",
0374:                        new BigDecimal("53443433.9784567")).whereAnd(
0375:                        "propertyBoolean", "=", false).whereOr("propertyByte",
0376:                        "=", (byte) 54).whereAnd("propertyCalendar", "<=", cal)
0377:                        .whereOr("propertyChar", "=", 'f').whereAnd(
0378:                                "propertyDate", "=", cal.getTime()).whereAnd(
0379:                                "propertyDouble", "!=", 73453.71d).whereOr(
0380:                                "propertyFloat", ">=", 1987.14f).whereAnd(
0381:                                "propertyInt", "=", 973).whereAnd(
0382:                                "propertyLong", "<", 347678L).whereAnd(
0383:                                "propertyShort", "=", (short) 78).whereOr(
0384:                                "propertySqlDate", "=",
0385:                                new java.sql.Date(cal.getTime().getTime()))
0386:                        .whereAnd("propertyString", "LIKE", "someotherstring%")
0387:                        .whereAnd("propertyStringbuffer", "=",
0388:                                new StringBuffer("someotherstringbuff"))
0389:                        .whereOr("propertyTime", "=",
0390:                                new Time(cal.getTime().getTime())).whereAnd(
0391:                                "propertyTimestamp", "<=",
0392:                                new Timestamp(cal.getTime().getTime()));
0393:
0394:                assertEquals(
0395:                        query.getSql(),
0396:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal >= 53443433.9784567 AND propertyBoolean = false OR propertyByte = 54 AND propertyCalendar <= TIMESTAMP '2003-03-03 10:01:28.154' OR propertyChar = 'f' AND propertyDate = TIMESTAMP '2003-03-03 10:01:28.154' AND propertyDouble != 73453.71 OR propertyFloat >= 1987.14 AND propertyInt = 973 AND propertyLong < 347678 AND propertyShort = 78 OR propertySqlDate = DATE '2003-03-03' AND propertyString LIKE 'someotherstring%' AND propertyStringbuffer = 'someotherstringbuff' OR propertyTime = TIME '10:01:28' AND propertyTimestamp <= TIMESTAMP '2003-03-03 10:01:28.154'");
0397:                assertFalse(execute(query));
0398:            }
0399:
0400:            public void testWhereTypedMixedMckoi() {
0401:                Update query = new Update(mMckoi);
0402:                query.table("tablename").field("propertyBoolean", true).field(
0403:                        "propertyByte", (byte) 16);
0404:
0405:                final Calendar cal = Calendar.getInstance();
0406:                cal.set(2003, 2, 3, 10, 1, 28);
0407:                cal.set(Calendar.MILLISECOND, 154);
0408:
0409:                query.where("propertyBigDecimal", ">=",
0410:                        new BigDecimal("53443433.9784567")).whereAnd(
0411:                        "propertyBoolean", "=", false).whereOr(
0412:                        "propertyByte = 54").whereAnd("propertyCalendar", "<=",
0413:                        cal).whereOr("propertyChar", "=", 'f').whereAnd(
0414:                        "propertyDate", "=", cal.getTime()).whereAnd(
0415:                        "propertyDouble", "!=", 73453.71d).whereOr(
0416:                        "propertyFloat >= 1987.14").whereAnd("propertyInt",
0417:                        "=", 973).whereAnd("propertyLong", "<", 347678L)
0418:                        .whereAnd("propertyShort", "=", (short) 78)
0419:                        .whereParameterOr("propertySqlDate", "=").whereAnd(
0420:                                "propertyString", "LIKE", "someotherstring%")
0421:                        .whereAnd("propertyStringbuffer", "=",
0422:                                new StringBuffer("someotherstringbuff"))
0423:                        .whereOr("propertyTime", "=",
0424:                                new Time(cal.getTime().getTime())).whereAnd(
0425:                                "propertyTimestamp", "<=",
0426:                                new Timestamp(cal.getTime().getTime()));
0427:
0428:                assertEquals(
0429:                        query.getSql(),
0430:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal >= 53443433.9784567 AND propertyBoolean = false OR propertyByte = 54 AND propertyCalendar <= TIMESTAMP '2003-03-03 10:01:28.154' OR propertyChar = 'f' AND propertyDate = TIMESTAMP '2003-03-03 10:01:28.154' AND propertyDouble != 73453.71 OR propertyFloat >= 1987.14 AND propertyInt = 973 AND propertyLong < 347678 AND propertyShort = 78 OR propertySqlDate = ? AND propertyString LIKE 'someotherstring%' AND propertyStringbuffer = 'someotherstringbuff' OR propertyTime = TIME '10:01:28' AND propertyTimestamp <= TIMESTAMP '2003-03-03 10:01:28.154'");
0431:
0432:                assertFalse(execute(query, new DbPreparedStatementHandler() {
0433:                    public void setParameters(DbPreparedStatement statement) {
0434:                        statement.setDate("propertySqlDate", new java.sql.Date(
0435:                                cal.getTime().getTime()));
0436:                    }
0437:                }));
0438:            }
0439:
0440:            public void testWhereParametersMckoi() {
0441:                Update query = new Update(mMckoi);
0442:                query.table("tablename").field("propertyBoolean", true).field(
0443:                        "propertyByte", (byte) 16);
0444:
0445:                assertNull(query.getParameters());
0446:
0447:                query.whereParameter("propertyInt", "=").whereParameterAnd(
0448:                        "propertyLong", "<").whereParameterOr("propertyChar",
0449:                        "=");
0450:
0451:                assertEquals(query.getParameters().getOrderedNames().size(), 3);
0452:                assertEquals(query.getParameters().getOrderedNames().get(0),
0453:                        "propertyInt");
0454:                assertEquals(query.getParameters().getOrderedNames().get(1),
0455:                        "propertyLong");
0456:                assertEquals(query.getParameters().getOrderedNames().get(2),
0457:                        "propertyChar");
0458:                assertTrue(Arrays.equals(query.getParameters()
0459:                        .getOrderedNamesArray(), new String[] { "propertyInt",
0460:                        "propertyLong", "propertyChar" }));
0461:
0462:                assertEquals(
0463:                        query.getSql(),
0464:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyInt = ? AND propertyLong < ? OR propertyChar = ?");
0465:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0466:                    public void setParameters(DbPreparedStatement statement) {
0467:                        statement.setInt(1, 545).setLong(2, 50000).setString(3,
0468:                                "v");
0469:                    }
0470:                }));
0471:
0472:                query.where("propertyInt = 545");
0473:
0474:                assertNull(query.getParameters());
0475:                assertEquals(
0476:                        query.getSql(),
0477:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyInt = 545");
0478:            }
0479:
0480:            public void testWhereParametersMixedMckoi() {
0481:                Update query = new Update(mMckoi);
0482:                query.table("tablename").field("propertyBoolean", true).field(
0483:                        "propertyByte", (byte) 16).where("propertyInt = 545")
0484:                        .whereParameterAnd("propertyLong", "<")
0485:                        .whereParameterOr("propertyChar", "=");
0486:
0487:                assertEquals(query.getParameters().getOrderedNames().get(0),
0488:                        "propertyLong");
0489:                assertEquals(query.getParameters().getOrderedNames().get(1),
0490:                        "propertyChar");
0491:                assertTrue(Arrays.equals(query.getParameters()
0492:                        .getOrderedNamesArray(), new String[] { "propertyLong",
0493:                        "propertyChar" }));
0494:
0495:                assertEquals(
0496:                        query.getSql(),
0497:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyInt = 545 AND propertyLong < ? OR propertyChar = ?");
0498:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0499:                    public void setParameters(DbPreparedStatement statement) {
0500:                        statement.setLong(1, 50000).setString(2, "v");
0501:                    }
0502:                }));
0503:
0504:                query.where("propertyInt = 545");
0505:
0506:                assertNull(query.getParameters());
0507:                assertEquals(
0508:                        query.getSql(),
0509:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyInt = 545");
0510:            }
0511:
0512:            public void testFieldWhereParametersMckoi() {
0513:                Update query = new Update(mMckoi);
0514:                query.table("tablename");
0515:
0516:                assertNull(query.getParameters());
0517:
0518:                query.fieldParameter("propertyBoolean").fieldParameter(
0519:                        "propertyByte");
0520:
0521:                assertEquals(query.getParameters().getOrderedNames().size(), 2);
0522:                assertEquals(query.getParameters().getOrderedNames().get(0),
0523:                        "propertyBoolean");
0524:                assertEquals(query.getParameters().getOrderedNames().get(1),
0525:                        "propertyByte");
0526:                assertTrue(Arrays.equals(query.getParameters()
0527:                        .getOrderedNamesArray(), new String[] {
0528:                        "propertyBoolean", "propertyByte" }));
0529:
0530:                query.whereParameter("propertyInt", "=").whereParameterAnd(
0531:                        "propertyLong", "<").whereParameterOr("propertyChar",
0532:                        "=");
0533:
0534:                assertEquals(query.getParameters().getOrderedNames().size(), 5);
0535:                assertEquals(query.getParameters().getOrderedNames().get(0),
0536:                        "propertyBoolean");
0537:                assertEquals(query.getParameters().getOrderedNames().get(1),
0538:                        "propertyByte");
0539:                assertEquals(query.getParameters().getOrderedNames().get(2),
0540:                        "propertyInt");
0541:                assertEquals(query.getParameters().getOrderedNames().get(3),
0542:                        "propertyLong");
0543:                assertEquals(query.getParameters().getOrderedNames().get(4),
0544:                        "propertyChar");
0545:                assertTrue(Arrays.equals(query.getParameters()
0546:                        .getOrderedNamesArray(), new String[] {
0547:                        "propertyBoolean", "propertyByte", "propertyInt",
0548:                        "propertyLong", "propertyChar" }));
0549:
0550:                assertEquals(
0551:                        query.getSql(),
0552:                        "UPDATE tablename SET propertyBoolean = ?, propertyByte = ? WHERE propertyInt = ? AND propertyLong < ? OR propertyChar = ?");
0553:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0554:                    public void setParameters(DbPreparedStatement statement) {
0555:                        statement.setBoolean(1, true).setByte(2, (byte) 16)
0556:                                .setInt(3, 545).setLong(4, 50000).setString(5,
0557:                                        "v");
0558:                    }
0559:                }));
0560:
0561:                query.where("propertyInt = 545");
0562:
0563:                assertEquals(query.getParameters().getOrderedNames().size(), 2);
0564:                assertEquals(
0565:                        query.getParameters().getOrderedNamesArray().length, 2);
0566:                assertEquals(query.getParameters().getOrderedNames().get(0),
0567:                        "propertyBoolean");
0568:                assertEquals(query.getParameters().getOrderedNames().get(1),
0569:                        "propertyByte");
0570:                assertTrue(Arrays.equals(query.getParameters()
0571:                        .getOrderedNamesArray(), new String[] {
0572:                        "propertyBoolean", "propertyByte" }));
0573:                assertEquals(
0574:                        query.getSql(),
0575:                        "UPDATE tablename SET propertyBoolean = ?, propertyByte = ? WHERE propertyInt = 545");
0576:            }
0577:
0578:            public void testFieldsBeanMckoi() {
0579:                Update query = new Update(mMckoi);
0580:                query.table("tablename").where("propertyInt = 545").fields(
0581:                        BeanImpl.getPopulatedBean());
0582:                assertEquals(
0583:                        query.getSql(),
0584:                        "UPDATE tablename SET propertyBigDecimal = 219038743.392874, propertyBoolean = true, propertyBooleanObject = false, propertyByte = 89, propertyByteObject = 34, propertyCalendar = TIMESTAMP '2002-06-18 15:26:14.764', propertyChar = 'v', propertyCharacterObject = 'r', propertyDate = TIMESTAMP '2002-06-18 15:26:14.764', propertyDouble = 53348.34, propertyDoubleObject = 143298.692, propertyEnum = 'VALUE_THREE', propertyFloat = 98634.2, propertyFloatObject = 8734.7, propertyInt = 545, propertyIntegerObject = 968, propertyLong = 34563, propertyLongObject = 66875, propertyShort = 43, propertyShortObject = 68, propertySqlDate = DATE '2002-06-18', propertyString = 'someotherstring', propertyStringbuffer = 'someotherstringbuff', propertyTime = TIME '15:26:14', propertyTimestamp = TIMESTAMP '2002-06-18 15:26:14.764' WHERE propertyInt = 545");
0585:                assertTrue(execute(query));
0586:            }
0587:
0588:            public void testFieldsBeanConstrainedMckoi() {
0589:                Update query = new Update(mMckoi);
0590:                query.table("tablename").where("propertyInt = 545").fields(
0591:                        BeanImplConstrained.getPopulatedBean());
0592:                assertEquals(
0593:                        query.getSql(),
0594:                        "UPDATE tablename SET propertyBigDecimal = 219038743.392874, propertyBoolean = true, propertyBooleanObject = false, propertyByteObject = 34, propertyCalendar = TIMESTAMP '2002-06-18 15:26:14.764', propertyChar = 'v', propertyCharacterObject = 'r', propertyDate = TIMESTAMP '2002-06-18 15:26:14.764', propertyDouble = 53348.34, propertyDoubleObject = 143298.692, propertyFloat = 98634.2, propertyFloatObject = 8734.7, propertyInt = 545, propertyIntegerObject = 968, propertyLongObject = 66875, propertyShort = 43, propertySqlDate = DATE '2002-06-18', propertyString = 'someotherstring', propertyStringbuffer = 'someotherstringbuff', propertyTime = TIME '15:26:14', propertyTimestamp = TIMESTAMP '2002-06-18 15:26:14.764' WHERE propertyInt = 545");
0595:                assertTrue(execute(query));
0596:            }
0597:
0598:            public void testFieldsBeanNullValuesMckoi() {
0599:                Update query = new Update(mMckoi);
0600:                query.table("tablename").where("propertyInt = 545").fields(
0601:                        BeanImpl.getNullBean());
0602:                assertEquals(
0603:                        query.getSql(),
0604:                        "UPDATE tablename SET propertyBoolean = false, propertyBooleanObject = false, propertyByte = 0, propertyByteObject = 0, propertyDouble = 0.0, propertyDoubleObject = 0.0, propertyFloat = 0.0, propertyFloatObject = 0.0, propertyInt = 0, propertyIntegerObject = 0, propertyLong = 0, propertyLongObject = 0, propertyShort = 0, propertyShortObject = 0 WHERE propertyInt = 545");
0605:                assertTrue(execute(query));
0606:            }
0607:
0608:            public void testFieldsBeanIncludedMckoi() {
0609:                Update query = new Update(mMckoi);
0610:                query
0611:                        .table("tablename")
0612:                        .where("propertyInt = 545")
0613:                        .fieldsIncluded(
0614:                                BeanImpl.getPopulatedBean(),
0615:                                new String[] { "propertyByte",
0616:                                        "propertyDouble", "propertyShort",
0617:                                        "propertyStringbuffer", "propertyTime" });
0618:                assertEquals(
0619:                        query.getSql(),
0620:                        "UPDATE tablename SET propertyByte = 89, propertyDouble = 53348.34, propertyShort = 43, propertyStringbuffer = 'someotherstringbuff', propertyTime = TIME '15:26:14' WHERE propertyInt = 545");
0621:                assertTrue(execute(query));
0622:            }
0623:
0624:            public void testFieldsBeanExcludedMckoi() {
0625:                Update query = new Update(mMckoi);
0626:                query
0627:                        .table("tablename")
0628:                        .where("propertyInt = 545")
0629:                        .fieldsExcluded(
0630:                                BeanImpl.getPopulatedBean(),
0631:                                new String[] { "propertyByte",
0632:                                        "propertyDouble", "propertyShort",
0633:                                        "propertyStringbuffer", "propertyTime" });
0634:                assertEquals(
0635:                        query.getSql(),
0636:                        "UPDATE tablename SET propertyBigDecimal = 219038743.392874, propertyBoolean = true, propertyBooleanObject = false, propertyByteObject = 34, propertyCalendar = TIMESTAMP '2002-06-18 15:26:14.764', propertyChar = 'v', propertyCharacterObject = 'r', propertyDate = TIMESTAMP '2002-06-18 15:26:14.764', propertyDoubleObject = 143298.692, propertyEnum = 'VALUE_THREE', propertyFloat = 98634.2, propertyFloatObject = 8734.7, propertyInt = 545, propertyIntegerObject = 968, propertyLong = 34563, propertyLongObject = 66875, propertyShortObject = 68, propertySqlDate = DATE '2002-06-18', propertyString = 'someotherstring', propertyTimestamp = TIMESTAMP '2002-06-18 15:26:14.764' WHERE propertyInt = 545");
0637:                assertTrue(execute(query));
0638:            }
0639:
0640:            public void testFieldsBeanFilteredMckoi() {
0641:                Update query = new Update(mMckoi);
0642:                query
0643:                        .table("tablename")
0644:                        .where("propertyInt = 545")
0645:                        .fieldsFiltered(
0646:                                BeanImpl.getPopulatedBean(),
0647:                                new String[] { "propertyByte",
0648:                                        "propertyDouble", "propertyShort",
0649:                                        "propertyStringbuffer", "propertyTime" },
0650:                                new String[] { "propertyByte", "propertyShort",
0651:                                        "propertyTime" });
0652:                assertEquals(
0653:                        query.getSql(),
0654:                        "UPDATE tablename SET propertyDouble = 53348.34, propertyStringbuffer = 'someotherstringbuff' WHERE propertyInt = 545");
0655:                assertTrue(execute(query));
0656:            }
0657:
0658:            public void testFieldsParametersBeanMckoi() {
0659:                Update query = new Update(mMckoi);
0660:                query.table("tablename").fieldsParameters(BeanImpl.class);
0661:                assertEquals(
0662:                        query.getSql(),
0663:                        "UPDATE tablename SET propertyBigDecimal = ?, propertyBoolean = ?, propertyBooleanObject = ?, propertyByte = ?, propertyByteObject = ?, propertyCalendar = ?, propertyChar = ?, propertyCharacterObject = ?, propertyDate = ?, propertyDouble = ?, propertyDoubleObject = ?, propertyEnum = ?, propertyFloat = ?, propertyFloatObject = ?, propertyInt = ?, propertyIntegerObject = ?, propertyLong = ?, propertyLongObject = ?, propertyShort = ?, propertyShortObject = ?, propertySqlDate = ?, propertyString = ?, propertyStringbuffer = ?, propertyTime = ?, propertyTimestamp = ?");
0664:
0665:                assertEquals(query.getParameters().getOrderedNames().size(), 25);
0666:                assertEquals(query.getParameters().getOrderedNames().get(0),
0667:                        "propertyBigDecimal");
0668:                assertEquals(query.getParameters().getOrderedNames().get(1),
0669:                        "propertyBoolean");
0670:                assertEquals(query.getParameters().getOrderedNames().get(2),
0671:                        "propertyBooleanObject");
0672:                assertEquals(query.getParameters().getOrderedNames().get(3),
0673:                        "propertyByte");
0674:                assertEquals(query.getParameters().getOrderedNames().get(4),
0675:                        "propertyByteObject");
0676:                assertEquals(query.getParameters().getOrderedNames().get(5),
0677:                        "propertyCalendar");
0678:                assertEquals(query.getParameters().getOrderedNames().get(6),
0679:                        "propertyChar");
0680:                assertEquals(query.getParameters().getOrderedNames().get(7),
0681:                        "propertyCharacterObject");
0682:                assertEquals(query.getParameters().getOrderedNames().get(8),
0683:                        "propertyDate");
0684:                assertEquals(query.getParameters().getOrderedNames().get(9),
0685:                        "propertyDouble");
0686:                assertEquals(query.getParameters().getOrderedNames().get(10),
0687:                        "propertyDoubleObject");
0688:                assertEquals(query.getParameters().getOrderedNames().get(11),
0689:                        "propertyEnum");
0690:                assertEquals(query.getParameters().getOrderedNames().get(12),
0691:                        "propertyFloat");
0692:                assertEquals(query.getParameters().getOrderedNames().get(13),
0693:                        "propertyFloatObject");
0694:                assertEquals(query.getParameters().getOrderedNames().get(14),
0695:                        "propertyInt");
0696:                assertEquals(query.getParameters().getOrderedNames().get(15),
0697:                        "propertyIntegerObject");
0698:                assertEquals(query.getParameters().getOrderedNames().get(16),
0699:                        "propertyLong");
0700:                assertEquals(query.getParameters().getOrderedNames().get(17),
0701:                        "propertyLongObject");
0702:                assertEquals(query.getParameters().getOrderedNames().get(18),
0703:                        "propertyShort");
0704:                assertEquals(query.getParameters().getOrderedNames().get(19),
0705:                        "propertyShortObject");
0706:                assertEquals(query.getParameters().getOrderedNames().get(20),
0707:                        "propertySqlDate");
0708:                assertEquals(query.getParameters().getOrderedNames().get(21),
0709:                        "propertyString");
0710:                assertEquals(query.getParameters().getOrderedNames().get(22),
0711:                        "propertyStringbuffer");
0712:                assertEquals(query.getParameters().getOrderedNames().get(23),
0713:                        "propertyTime");
0714:                assertEquals(query.getParameters().getOrderedNames().get(24),
0715:                        "propertyTimestamp");
0716:                assertTrue(Arrays.equals(query.getParameters()
0717:                        .getOrderedNamesArray(), new String[] {
0718:                        "propertyBigDecimal", "propertyBoolean",
0719:                        "propertyBooleanObject", "propertyByte",
0720:                        "propertyByteObject", "propertyCalendar",
0721:                        "propertyChar", "propertyCharacterObject",
0722:                        "propertyDate", "propertyDouble",
0723:                        "propertyDoubleObject", "propertyEnum",
0724:                        "propertyFloat", "propertyFloatObject", "propertyInt",
0725:                        "propertyIntegerObject", "propertyLong",
0726:                        "propertyLongObject", "propertyShort",
0727:                        "propertyShortObject", "propertySqlDate",
0728:                        "propertyString", "propertyStringbuffer",
0729:                        "propertyTime", "propertyTimestamp" }));
0730:
0731:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0732:                    public void setParameters(DbPreparedStatement statement) {
0733:                        Calendar cal = Calendar.getInstance();
0734:                        cal.set(2002, 7, 19, 12, 17, 52);
0735:                        cal.set(Calendar.MILLISECOND, 462);
0736:                        statement.setBigDecimal(1,
0737:                                new BigDecimal("98347.876438637")).setBoolean(
0738:                                2, false).setBoolean(3, true).setByte(4,
0739:                                (byte) 16).setByte(5, (byte) 72)
0740:                                .setTimestamp(
0741:                                        6,
0742:                                        new java.sql.Timestamp(cal.getTime()
0743:                                                .getTime())).setString(7, "M")
0744:                                .setString(8, "p").setTimestamp(
0745:                                        9,
0746:                                        new java.sql.Timestamp(cal.getTime()
0747:                                                .getTime())).setDouble(10,
0748:                                        12.3d).setDouble(11, 68.7d).setString(
0749:                                        12, "VALUE_THREE").setFloat(13, 13.4f)
0750:                                .setFloat(14, 42.1f).setInt(15, 92).setInt(16,
0751:                                        34).setLong(17, 687L).setLong(18, 92)
0752:                                .setShort(19, (short) 7).setShort(20,
0753:                                        (short) 12).setDate(
0754:                                        21,
0755:                                        new java.sql.Date(cal.getTime()
0756:                                                .getTime())).setString(22,
0757:                                        "string'value").setString(23,
0758:                                        "string'value2").setTime(24,
0759:                                        new Time(cal.getTime().getTime()))
0760:                                .setTimestamp(25,
0761:                                        new Timestamp(cal.getTime().getTime()));
0762:                    }
0763:                }));
0764:            }
0765:
0766:            public void testFieldsParametersBeanConstrainedMckoi() {
0767:                Update query = new Update(mMckoi);
0768:                query.table("tablename").fieldsParameters(
0769:                        BeanImplConstrained.class);
0770:                assertEquals(
0771:                        query.getSql(),
0772:                        "UPDATE tablename SET propertyBigDecimal = ?, propertyBoolean = ?, propertyBooleanObject = ?, propertyByteObject = ?, propertyCalendar = ?, propertyChar = ?, propertyCharacterObject = ?, propertyDate = ?, propertyDouble = ?, propertyDoubleObject = ?, propertyFloat = ?, propertyFloatObject = ?, propertyInt = ?, propertyIntegerObject = ?, propertyLongObject = ?, propertyShort = ?, propertySqlDate = ?, propertyString = ?, propertyStringbuffer = ?, propertyTime = ?, propertyTimestamp = ?");
0773:
0774:                assertEquals(query.getParameters().getOrderedNames().size(), 21);
0775:                assertEquals(query.getParameters().getOrderedNames().get(0),
0776:                        "propertyBigDecimal");
0777:                assertEquals(query.getParameters().getOrderedNames().get(1),
0778:                        "propertyBoolean");
0779:                assertEquals(query.getParameters().getOrderedNames().get(2),
0780:                        "propertyBooleanObject");
0781:                assertEquals(query.getParameters().getOrderedNames().get(3),
0782:                        "propertyByteObject");
0783:                assertEquals(query.getParameters().getOrderedNames().get(4),
0784:                        "propertyCalendar");
0785:                assertEquals(query.getParameters().getOrderedNames().get(5),
0786:                        "propertyChar");
0787:                assertEquals(query.getParameters().getOrderedNames().get(6),
0788:                        "propertyCharacterObject");
0789:                assertEquals(query.getParameters().getOrderedNames().get(7),
0790:                        "propertyDate");
0791:                assertEquals(query.getParameters().getOrderedNames().get(8),
0792:                        "propertyDouble");
0793:                assertEquals(query.getParameters().getOrderedNames().get(9),
0794:                        "propertyDoubleObject");
0795:                assertEquals(query.getParameters().getOrderedNames().get(10),
0796:                        "propertyFloat");
0797:                assertEquals(query.getParameters().getOrderedNames().get(11),
0798:                        "propertyFloatObject");
0799:                assertEquals(query.getParameters().getOrderedNames().get(12),
0800:                        "propertyInt");
0801:                assertEquals(query.getParameters().getOrderedNames().get(13),
0802:                        "propertyIntegerObject");
0803:                assertEquals(query.getParameters().getOrderedNames().get(14),
0804:                        "propertyLongObject");
0805:                assertEquals(query.getParameters().getOrderedNames().get(15),
0806:                        "propertyShort");
0807:                assertEquals(query.getParameters().getOrderedNames().get(16),
0808:                        "propertySqlDate");
0809:                assertEquals(query.getParameters().getOrderedNames().get(17),
0810:                        "propertyString");
0811:                assertEquals(query.getParameters().getOrderedNames().get(18),
0812:                        "propertyStringbuffer");
0813:                assertEquals(query.getParameters().getOrderedNames().get(19),
0814:                        "propertyTime");
0815:                assertEquals(query.getParameters().getOrderedNames().get(20),
0816:                        "propertyTimestamp");
0817:                assertTrue(Arrays.equals(query.getParameters()
0818:                        .getOrderedNamesArray(), new String[] {
0819:                        "propertyBigDecimal", "propertyBoolean",
0820:                        "propertyBooleanObject", "propertyByteObject",
0821:                        "propertyCalendar", "propertyChar",
0822:                        "propertyCharacterObject", "propertyDate",
0823:                        "propertyDouble", "propertyDoubleObject",
0824:                        "propertyFloat", "propertyFloatObject", "propertyInt",
0825:                        "propertyIntegerObject", "propertyLongObject",
0826:                        "propertyShort", "propertySqlDate", "propertyString",
0827:                        "propertyStringbuffer", "propertyTime",
0828:                        "propertyTimestamp" }));
0829:
0830:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0831:                    public void setParameters(DbPreparedStatement statement) {
0832:                        Calendar cal = Calendar.getInstance();
0833:                        cal.set(2002, 7, 19, 12, 17, 52);
0834:                        cal.set(Calendar.MILLISECOND, 462);
0835:                        statement.setBigDecimal(1,
0836:                                new BigDecimal("98347.876438637")).setBoolean(
0837:                                2, false).setBoolean(3, true).setByte(4,
0838:                                (byte) 72)
0839:                                .setTimestamp(
0840:                                        5,
0841:                                        new java.sql.Timestamp(cal.getTime()
0842:                                                .getTime())).setString(6, "M")
0843:                                .setString(7, "p").setTimestamp(
0844:                                        8,
0845:                                        new java.sql.Timestamp(cal.getTime()
0846:                                                .getTime()))
0847:                                .setDouble(9, 12.3d).setDouble(10, 68.7d)
0848:                                .setFloat(11, 13.4f).setFloat(12, 42.1f)
0849:                                .setInt(13, 92).setInt(14, 34).setLong(15, 92)
0850:                                .setShort(16, (short) 7).setDate(
0851:                                        17,
0852:                                        new java.sql.Date(cal.getTime()
0853:                                                .getTime())).setString(18,
0854:                                        "string'value").setString(19,
0855:                                        "string'value2").setTime(20,
0856:                                        new Time(cal.getTime().getTime()))
0857:                                .setTimestamp(21,
0858:                                        new Timestamp(cal.getTime().getTime()));
0859:                    }
0860:                }));
0861:            }
0862:
0863:            public void testFieldsParametersBeanExcludedMckoi() {
0864:                Update query = new Update(mMckoi);
0865:                query.table("tablename").fieldsParametersExcluded(
0866:                        BeanImpl.class,
0867:                        new String[] { "propertyBoolean", "propertyByte",
0868:                                "propertyChar", "propertyDouble",
0869:                                "propertyInt", "propertyLong",
0870:                                "propertySqlDate", "propertyStringbuffer",
0871:                                "propertyTimestamp" });
0872:                assertEquals(
0873:                        query.getSql(),
0874:                        "UPDATE tablename SET propertyBigDecimal = ?, propertyBooleanObject = ?, propertyByteObject = ?, propertyCalendar = ?, propertyCharacterObject = ?, propertyDate = ?, propertyDoubleObject = ?, propertyEnum = ?, propertyFloat = ?, propertyFloatObject = ?, propertyIntegerObject = ?, propertyLongObject = ?, propertyShort = ?, propertyShortObject = ?, propertyString = ?, propertyTime = ?");
0875:
0876:                assertEquals(query.getParameters().getOrderedNames().size(), 16);
0877:                assertEquals(query.getParameters().getOrderedNames().get(0),
0878:                        "propertyBigDecimal");
0879:                assertEquals(query.getParameters().getOrderedNames().get(1),
0880:                        "propertyBooleanObject");
0881:                assertEquals(query.getParameters().getOrderedNames().get(2),
0882:                        "propertyByteObject");
0883:                assertEquals(query.getParameters().getOrderedNames().get(3),
0884:                        "propertyCalendar");
0885:                assertEquals(query.getParameters().getOrderedNames().get(4),
0886:                        "propertyCharacterObject");
0887:                assertEquals(query.getParameters().getOrderedNames().get(5),
0888:                        "propertyDate");
0889:                assertEquals(query.getParameters().getOrderedNames().get(6),
0890:                        "propertyDoubleObject");
0891:                assertEquals(query.getParameters().getOrderedNames().get(7),
0892:                        "propertyEnum");
0893:                assertEquals(query.getParameters().getOrderedNames().get(8),
0894:                        "propertyFloat");
0895:                assertEquals(query.getParameters().getOrderedNames().get(9),
0896:                        "propertyFloatObject");
0897:                assertEquals(query.getParameters().getOrderedNames().get(10),
0898:                        "propertyIntegerObject");
0899:                assertEquals(query.getParameters().getOrderedNames().get(11),
0900:                        "propertyLongObject");
0901:                assertEquals(query.getParameters().getOrderedNames().get(12),
0902:                        "propertyShort");
0903:                assertEquals(query.getParameters().getOrderedNames().get(13),
0904:                        "propertyShortObject");
0905:                assertEquals(query.getParameters().getOrderedNames().get(14),
0906:                        "propertyString");
0907:                assertEquals(query.getParameters().getOrderedNames().get(15),
0908:                        "propertyTime");
0909:                assertTrue(Arrays.equals(query.getParameters()
0910:                        .getOrderedNamesArray(), new String[] {
0911:                        "propertyBigDecimal", "propertyBooleanObject",
0912:                        "propertyByteObject", "propertyCalendar",
0913:                        "propertyCharacterObject", "propertyDate",
0914:                        "propertyDoubleObject", "propertyEnum",
0915:                        "propertyFloat", "propertyFloatObject",
0916:                        "propertyIntegerObject", "propertyLongObject",
0917:                        "propertyShort", "propertyShortObject",
0918:                        "propertyString", "propertyTime" }));
0919:
0920:                assertTrue(execute(query, new DbPreparedStatementHandler() {
0921:                    public void setParameters(DbPreparedStatement statement) {
0922:                        Calendar cal = Calendar.getInstance();
0923:                        cal.set(2002, 7, 19, 12, 17, 52);
0924:                        cal.set(Calendar.MILLISECOND, 462);
0925:                        statement.setBigDecimal(1,
0926:                                new BigDecimal("98347.876438637")).setBoolean(
0927:                                2, true).setByte(3, (byte) 72)
0928:                                .setTimestamp(
0929:                                        4,
0930:                                        new java.sql.Timestamp(cal.getTime()
0931:                                                .getTime())).setString(5, "o")
0932:                                .setTimestamp(
0933:                                        6,
0934:                                        new java.sql.Timestamp(cal.getTime()
0935:                                                .getTime()))
0936:                                .setDouble(7, 86.7d)
0937:                                .setString(8, "VALUE_THREE").setFloat(9, 13.4f)
0938:                                .setFloat(10, 32.8f).setInt(11, 358).setLong(
0939:                                        12, 9680L).setShort(13, (short) 12)
0940:                                .setShort(14, (short) 78).setString(15,
0941:                                        "string'value").setTime(16,
0942:                                        new Time(cal.getTime().getTime()));
0943:                    }
0944:                }));
0945:            }
0946:
0947:            public void testWhereBeanMckoi() {
0948:                Update query = new Update(mMckoi);
0949:                query.table("tablename").field("propertyBoolean", true).field(
0950:                        "propertyByte", (byte) 16).where(
0951:                        BeanImpl.getPopulatedBean());
0952:                assertEquals(
0953:                        query.getSql(),
0954:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal = 219038743.392874 AND propertyBoolean = true AND propertyBooleanObject = false AND propertyByte = 89 AND propertyByteObject = 34 AND propertyCalendar = TIMESTAMP '2002-06-18 15:26:14.764' AND propertyChar = 'v' AND propertyCharacterObject = 'r' AND propertyDate = TIMESTAMP '2002-06-18 15:26:14.764' AND propertyDouble = 53348.34 AND propertyDoubleObject = 143298.692 AND propertyEnum = 'VALUE_THREE' AND propertyFloat = 98634.2 AND propertyFloatObject = 8734.7 AND propertyInt = 545 AND propertyIntegerObject = 968 AND propertyLong = 34563 AND propertyLongObject = 66875 AND propertyShort = 43 AND propertyShortObject = 68 AND propertySqlDate = DATE '2002-06-18' AND propertyString = 'someotherstring' AND propertyStringbuffer = 'someotherstringbuff' AND propertyTime = TIME '15:26:14' AND propertyTimestamp = TIMESTAMP '2002-06-18 15:26:14.764'");
0955:                assertTrue(execute(query));
0956:            }
0957:
0958:            public void testWhereBeanConstrainedMckoi() {
0959:                Update query = new Update(mMckoi);
0960:                query.table("tablename").field("propertyBoolean", true).field(
0961:                        "propertyByte", (byte) 16).where(
0962:                        BeanImplConstrained.getPopulatedBean());
0963:                assertEquals(
0964:                        query.getSql(),
0965:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal = 219038743.392874 AND propertyBoolean = true AND propertyBooleanObject = false AND propertyByte = 89 AND propertyByteObject = 34 AND propertyCalendar = TIMESTAMP '2002-06-18 15:26:14.764' AND propertyChar = 'v' AND propertyCharacterObject = 'r' AND propertyDate = TIMESTAMP '2002-06-18 15:26:14.764' AND propertyDouble = 53348.34 AND propertyDoubleObject = 143298.692 AND propertyFloat = 98634.2 AND propertyFloatObject = 8734.7 AND propertyInt = 545 AND propertyIntegerObject = 968 AND propertyLongObject = 66875 AND propertyShort = 43 AND propertySqlDate = DATE '2002-06-18' AND propertyString = 'someotherstring' AND propertyStringbuffer = 'someotherstringbuff' AND propertyTime = TIME '15:26:14' AND propertyTimestamp = TIMESTAMP '2002-06-18 15:26:14.764'");
0966:                assertTrue(execute(query));
0967:            }
0968:
0969:            public void testWhereBeanNullValuesMckoi() {
0970:                Update query = new Update(mMckoi);
0971:                query.table("tablename").field("propertyBoolean", true).field(
0972:                        "propertyByte", (byte) 16)
0973:                        .where(BeanImpl.getNullBean());
0974:                assertEquals(
0975:                        query.getSql(),
0976:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBoolean = false AND propertyBooleanObject = false AND propertyByte = 0 AND propertyByteObject = 0 AND propertyDouble = 0.0 AND propertyDoubleObject = 0.0 AND propertyFloat = 0.0 AND propertyFloatObject = 0.0 AND propertyInt = 0 AND propertyIntegerObject = 0 AND propertyLong = 0 AND propertyLongObject = 0 AND propertyShort = 0 AND propertyShortObject = 0");
0977:                assertTrue(execute(query));
0978:            }
0979:
0980:            public void testWhereBeanIncludedMckoi() {
0981:                Update query = new Update(mMckoi);
0982:                query.table("tablename").field("propertyBoolean", true).field(
0983:                        "propertyByte", (byte) 16).whereIncluded(
0984:                        BeanImpl.getPopulatedBean(),
0985:                        new String[] { "propertyByte", "propertyDouble",
0986:                                "propertyShort", "propertyStringbuffer",
0987:                                "propertyTime" });
0988:                assertEquals(
0989:                        query.getSql(),
0990:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyByte = 89 AND propertyDouble = 53348.34 AND propertyShort = 43 AND propertyStringbuffer = 'someotherstringbuff' AND propertyTime = TIME '15:26:14'");
0991:                assertTrue(execute(query));
0992:            }
0993:
0994:            public void testWhereBeanExcludedMckoi() {
0995:                Update query = new Update(mMckoi);
0996:                query.table("tablename").field("propertyBoolean", true).field(
0997:                        "propertyByte", (byte) 16).whereExcluded(
0998:                        BeanImpl.getPopulatedBean(),
0999:                        new String[] { "propertyByte", "propertyDouble",
1000:                                "propertyShort", "propertyStringbuffer",
1001:                                "propertyTime" });
1002:                assertEquals(
1003:                        query.getSql(),
1004:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal = 219038743.392874 AND propertyBoolean = true AND propertyBooleanObject = false AND propertyByteObject = 34 AND propertyCalendar = TIMESTAMP '2002-06-18 15:26:14.764' AND propertyChar = 'v' AND propertyCharacterObject = 'r' AND propertyDate = TIMESTAMP '2002-06-18 15:26:14.764' AND propertyDoubleObject = 143298.692 AND propertyEnum = 'VALUE_THREE' AND propertyFloat = 98634.2 AND propertyFloatObject = 8734.7 AND propertyInt = 545 AND propertyIntegerObject = 968 AND propertyLong = 34563 AND propertyLongObject = 66875 AND propertyShortObject = 68 AND propertySqlDate = DATE '2002-06-18' AND propertyString = 'someotherstring' AND propertyTimestamp = TIMESTAMP '2002-06-18 15:26:14.764'");
1005:                assertTrue(execute(query));
1006:            }
1007:
1008:            public void testWhereBeanFilteredMckoi() {
1009:                Update query = new Update(mMckoi);
1010:                query.table("tablename").field("propertyBoolean", true).field(
1011:                        "propertyByte", (byte) 16).whereFiltered(
1012:                        BeanImpl.getPopulatedBean(),
1013:                        new String[] { "propertyByte", "propertyDouble",
1014:                                "propertyShort", "propertyStringbuffer",
1015:                                "propertyTime" },
1016:                        new String[] { "propertyByte", "propertyShort",
1017:                                "propertyTime" });
1018:                assertEquals(
1019:                        query.getSql(),
1020:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyDouble = 53348.34 AND propertyStringbuffer = 'someotherstringbuff'");
1021:                assertTrue(execute(query));
1022:            }
1023:
1024:            public void testWhereParametersBeanMckoi() {
1025:                Update query = new Update(mMckoi);
1026:                query.table("tablename").field("propertyBoolean", true).field(
1027:                        "propertyByte", (byte) 16).whereParameters(
1028:                        BeanImpl.class);
1029:                assertEquals(
1030:                        query.getSql(),
1031:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal = ? AND propertyBoolean = ? AND propertyBooleanObject = ? AND propertyByte = ? AND propertyByteObject = ? AND propertyCalendar = ? AND propertyChar = ? AND propertyCharacterObject = ? AND propertyDate = ? AND propertyDouble = ? AND propertyDoubleObject = ? AND propertyEnum = ? AND propertyFloat = ? AND propertyFloatObject = ? AND propertyInt = ? AND propertyIntegerObject = ? AND propertyLong = ? AND propertyLongObject = ? AND propertyShort = ? AND propertyShortObject = ? AND propertySqlDate = ? AND propertyString = ? AND propertyStringbuffer = ? AND propertyTime = ? AND propertyTimestamp = ?");
1032:
1033:                assertEquals(query.getParameters().getOrderedNames().size(), 25);
1034:                assertEquals(query.getParameters().getOrderedNames().get(0),
1035:                        "propertyBigDecimal");
1036:                assertEquals(query.getParameters().getOrderedNames().get(1),
1037:                        "propertyBoolean");
1038:                assertEquals(query.getParameters().getOrderedNames().get(2),
1039:                        "propertyBooleanObject");
1040:                assertEquals(query.getParameters().getOrderedNames().get(3),
1041:                        "propertyByte");
1042:                assertEquals(query.getParameters().getOrderedNames().get(4),
1043:                        "propertyByteObject");
1044:                assertEquals(query.getParameters().getOrderedNames().get(5),
1045:                        "propertyCalendar");
1046:                assertEquals(query.getParameters().getOrderedNames().get(6),
1047:                        "propertyChar");
1048:                assertEquals(query.getParameters().getOrderedNames().get(7),
1049:                        "propertyCharacterObject");
1050:                assertEquals(query.getParameters().getOrderedNames().get(8),
1051:                        "propertyDate");
1052:                assertEquals(query.getParameters().getOrderedNames().get(9),
1053:                        "propertyDouble");
1054:                assertEquals(query.getParameters().getOrderedNames().get(10),
1055:                        "propertyDoubleObject");
1056:                assertEquals(query.getParameters().getOrderedNames().get(11),
1057:                        "propertyEnum");
1058:                assertEquals(query.getParameters().getOrderedNames().get(12),
1059:                        "propertyFloat");
1060:                assertEquals(query.getParameters().getOrderedNames().get(13),
1061:                        "propertyFloatObject");
1062:                assertEquals(query.getParameters().getOrderedNames().get(14),
1063:                        "propertyInt");
1064:                assertEquals(query.getParameters().getOrderedNames().get(15),
1065:                        "propertyIntegerObject");
1066:                assertEquals(query.getParameters().getOrderedNames().get(16),
1067:                        "propertyLong");
1068:                assertEquals(query.getParameters().getOrderedNames().get(17),
1069:                        "propertyLongObject");
1070:                assertEquals(query.getParameters().getOrderedNames().get(18),
1071:                        "propertyShort");
1072:                assertEquals(query.getParameters().getOrderedNames().get(19),
1073:                        "propertyShortObject");
1074:                assertEquals(query.getParameters().getOrderedNames().get(20),
1075:                        "propertySqlDate");
1076:                assertEquals(query.getParameters().getOrderedNames().get(21),
1077:                        "propertyString");
1078:                assertEquals(query.getParameters().getOrderedNames().get(22),
1079:                        "propertyStringbuffer");
1080:                assertEquals(query.getParameters().getOrderedNames().get(23),
1081:                        "propertyTime");
1082:                assertEquals(query.getParameters().getOrderedNames().get(24),
1083:                        "propertyTimestamp");
1084:                assertTrue(Arrays.equals(query.getParameters()
1085:                        .getOrderedNamesArray(), new String[] {
1086:                        "propertyBigDecimal", "propertyBoolean",
1087:                        "propertyBooleanObject", "propertyByte",
1088:                        "propertyByteObject", "propertyCalendar",
1089:                        "propertyChar", "propertyCharacterObject",
1090:                        "propertyDate", "propertyDouble",
1091:                        "propertyDoubleObject", "propertyEnum",
1092:                        "propertyFloat", "propertyFloatObject", "propertyInt",
1093:                        "propertyIntegerObject", "propertyLong",
1094:                        "propertyLongObject", "propertyShort",
1095:                        "propertyShortObject", "propertySqlDate",
1096:                        "propertyString", "propertyStringbuffer",
1097:                        "propertyTime", "propertyTimestamp" }));
1098:
1099:                assertTrue(execute(query, new DbPreparedStatementHandler() {
1100:                    public void setParameters(DbPreparedStatement statement) {
1101:                        Calendar cal = Calendar.getInstance();
1102:                        cal.set(2002, 5, 18, 15, 26, 14);
1103:                        cal.set(Calendar.MILLISECOND, 764);
1104:                        java.sql.Date date = new java.sql.Date(102, 5, 18);
1105:                        Time time = new Time(15, 26, 14);
1106:                        statement.setBigDecimal(1,
1107:                                new BigDecimal("219038743.392874")).setBoolean(
1108:                                2, true).setBoolean(3, false).setByte(4,
1109:                                (byte) 89).setByte(5, (byte) 34)
1110:                                .setTimestamp(
1111:                                        6,
1112:                                        new java.sql.Timestamp(cal.getTime()
1113:                                                .getTime())).setString(7, "v")
1114:                                .setString(8, "r").setTimestamp(
1115:                                        9,
1116:                                        new java.sql.Timestamp(cal.getTime()
1117:                                                .getTime())).setDouble(10,
1118:                                        53348.34d).setDouble(11, 143298.692d)
1119:                                .setString(12, "VALUE_THREE").setFloat(13,
1120:                                        98634.2f).setFloat(14, 8734.7f).setInt(
1121:                                        15, 545).setInt(16, 968).setLong(17,
1122:                                        34563L).setLong(18, 66875L).setShort(
1123:                                        19, (short) 43)
1124:                                .setShort(20, (short) 68).setDate(21, date)
1125:                                .setString(22, "someotherstring").setString(23,
1126:                                        "someotherstringbuff")
1127:                                .setTime(24, time).setTimestamp(25,
1128:                                        new Timestamp(cal.getTime().getTime()));
1129:                    }
1130:                }));
1131:            }
1132:
1133:            public void testWhereParametersBeanConstrainedMckoi() {
1134:                Update query = new Update(mMckoi);
1135:                query.table("tablename").field("propertyBoolean", true).field(
1136:                        "propertyByte", (byte) 16).whereParameters(
1137:                        BeanImplConstrained.class);
1138:                assertEquals(
1139:                        query.getSql(),
1140:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal = ? AND propertyBoolean = ? AND propertyBooleanObject = ? AND propertyByte = ? AND propertyByteObject = ? AND propertyCalendar = ? AND propertyChar = ? AND propertyCharacterObject = ? AND propertyDate = ? AND propertyDouble = ? AND propertyDoubleObject = ? AND propertyFloat = ? AND propertyFloatObject = ? AND propertyInt = ? AND propertyIntegerObject = ? AND propertyLongObject = ? AND propertyShort = ? AND propertySqlDate = ? AND propertyString = ? AND propertyStringbuffer = ? AND propertyTime = ? AND propertyTimestamp = ?");
1141:
1142:                assertEquals(query.getParameters().getOrderedNames().size(), 22);
1143:                assertEquals(query.getParameters().getOrderedNames().get(0),
1144:                        "propertyBigDecimal");
1145:                assertEquals(query.getParameters().getOrderedNames().get(1),
1146:                        "propertyBoolean");
1147:                assertEquals(query.getParameters().getOrderedNames().get(2),
1148:                        "propertyBooleanObject");
1149:                assertEquals(query.getParameters().getOrderedNames().get(3),
1150:                        "propertyByte");
1151:                assertEquals(query.getParameters().getOrderedNames().get(4),
1152:                        "propertyByteObject");
1153:                assertEquals(query.getParameters().getOrderedNames().get(5),
1154:                        "propertyCalendar");
1155:                assertEquals(query.getParameters().getOrderedNames().get(6),
1156:                        "propertyChar");
1157:                assertEquals(query.getParameters().getOrderedNames().get(7),
1158:                        "propertyCharacterObject");
1159:                assertEquals(query.getParameters().getOrderedNames().get(8),
1160:                        "propertyDate");
1161:                assertEquals(query.getParameters().getOrderedNames().get(9),
1162:                        "propertyDouble");
1163:                assertEquals(query.getParameters().getOrderedNames().get(10),
1164:                        "propertyDoubleObject");
1165:                assertEquals(query.getParameters().getOrderedNames().get(11),
1166:                        "propertyFloat");
1167:                assertEquals(query.getParameters().getOrderedNames().get(12),
1168:                        "propertyFloatObject");
1169:                assertEquals(query.getParameters().getOrderedNames().get(13),
1170:                        "propertyInt");
1171:                assertEquals(query.getParameters().getOrderedNames().get(14),
1172:                        "propertyIntegerObject");
1173:                assertEquals(query.getParameters().getOrderedNames().get(15),
1174:                        "propertyLongObject");
1175:                assertEquals(query.getParameters().getOrderedNames().get(16),
1176:                        "propertyShort");
1177:                assertEquals(query.getParameters().getOrderedNames().get(17),
1178:                        "propertySqlDate");
1179:                assertEquals(query.getParameters().getOrderedNames().get(18),
1180:                        "propertyString");
1181:                assertEquals(query.getParameters().getOrderedNames().get(19),
1182:                        "propertyStringbuffer");
1183:                assertEquals(query.getParameters().getOrderedNames().get(20),
1184:                        "propertyTime");
1185:                assertEquals(query.getParameters().getOrderedNames().get(21),
1186:                        "propertyTimestamp");
1187:                assertTrue(Arrays.equals(query.getParameters()
1188:                        .getOrderedNamesArray(), new String[] {
1189:                        "propertyBigDecimal", "propertyBoolean",
1190:                        "propertyBooleanObject", "propertyByte",
1191:                        "propertyByteObject", "propertyCalendar",
1192:                        "propertyChar", "propertyCharacterObject",
1193:                        "propertyDate", "propertyDouble",
1194:                        "propertyDoubleObject", "propertyFloat",
1195:                        "propertyFloatObject", "propertyInt",
1196:                        "propertyIntegerObject", "propertyLongObject",
1197:                        "propertyShort", "propertySqlDate", "propertyString",
1198:                        "propertyStringbuffer", "propertyTime",
1199:                        "propertyTimestamp" }));
1200:
1201:                assertTrue(execute(query, new DbPreparedStatementHandler() {
1202:                    public void setParameters(DbPreparedStatement statement) {
1203:                        Calendar cal = Calendar.getInstance();
1204:                        cal.set(2002, 5, 18, 15, 26, 14);
1205:                        cal.set(Calendar.MILLISECOND, 764);
1206:                        java.sql.Date date = new java.sql.Date(102, 5, 18);
1207:                        Time time = new Time(15, 26, 14);
1208:                        statement.setBigDecimal(1,
1209:                                new BigDecimal("219038743.392874")).setBoolean(
1210:                                2, true).setBoolean(3, false).setByte(4,
1211:                                (byte) 89).setByte(5, (byte) 34)
1212:                                .setTimestamp(
1213:                                        6,
1214:                                        new java.sql.Timestamp(cal.getTime()
1215:                                                .getTime())).setString(7, "v")
1216:                                .setString(8, "r").setTimestamp(
1217:                                        9,
1218:                                        new java.sql.Timestamp(cal.getTime()
1219:                                                .getTime())).setDouble(10,
1220:                                        53348.34d).setDouble(11, 143298.692d)
1221:                                .setFloat(12, 98634.2f).setFloat(13, 8734.7f)
1222:                                .setInt(14, 545).setInt(15, 968).setLong(16,
1223:                                        66875L).setShort(17, (short) 43)
1224:                                .setDate(18, date).setString(19,
1225:                                        "someotherstring").setString(20,
1226:                                        "someotherstringbuff")
1227:                                .setTime(21, time).setTimestamp(22,
1228:                                        new Timestamp(cal.getTime().getTime()));
1229:                    }
1230:                }));
1231:            }
1232:
1233:            public void testWhereParametersBeanExcludedMckoi() {
1234:                Update query = new Update(mMckoi);
1235:                query.table("tablename").field("propertyBoolean", true).field(
1236:                        "propertyByte", (byte) 16).whereParametersExcluded(
1237:                        BeanImpl.class,
1238:                        new String[] { "propertyBoolean", "propertyByte",
1239:                                "propertyChar", "propertyDouble",
1240:                                "propertyInt", "propertyLong",
1241:                                "propertySqlDate", "propertyStringbuffer",
1242:                                "propertyTimestamp" });
1243:                assertEquals(
1244:                        query.getSql(),
1245:                        "UPDATE tablename SET propertyBoolean = true, propertyByte = 16 WHERE propertyBigDecimal = ? AND propertyBooleanObject = ? AND propertyByteObject = ? AND propertyCalendar = ? AND propertyCharacterObject = ? AND propertyDate = ? AND propertyDoubleObject = ? AND propertyEnum = ? AND propertyFloat = ? AND propertyFloatObject = ? AND propertyIntegerObject = ? AND propertyLongObject = ? AND propertyShort = ? AND propertyShortObject = ? AND propertyString = ? AND propertyTime = ?");
1246:
1247:                assertEquals(query.getParameters().getOrderedNames().size(), 16);
1248:                assertEquals(query.getParameters().getOrderedNames().get(0),
1249:                        "propertyBigDecimal");
1250:                assertEquals(query.getParameters().getOrderedNames().get(1),
1251:                        "propertyBooleanObject");
1252:                assertEquals(query.getParameters().getOrderedNames().get(2),
1253:                        "propertyByteObject");
1254:                assertEquals(query.getParameters().getOrderedNames().get(3),
1255:                        "propertyCalendar");
1256:                assertEquals(query.getParameters().getOrderedNames().get(4),
1257:                        "propertyCharacterObject");
1258:                assertEquals(query.getParameters().getOrderedNames().get(5),
1259:                        "propertyDate");
1260:                assertEquals(query.getParameters().getOrderedNames().get(6),
1261:                        "propertyDoubleObject");
1262:                assertEquals(query.getParameters().getOrderedNames().get(7),
1263:                        "propertyEnum");
1264:                assertEquals(query.getParameters().getOrderedNames().get(8),
1265:                        "propertyFloat");
1266:                assertEquals(query.getParameters().getOrderedNames().get(9),
1267:                        "propertyFloatObject");
1268:                assertEquals(query.getParameters().getOrderedNames().get(10),
1269:                        "propertyIntegerObject");
1270:                assertEquals(query.getParameters().getOrderedNames().get(11),
1271:                        "propertyLongObject");
1272:                assertEquals(query.getParameters().getOrderedNames().get(12),
1273:                        "propertyShort");
1274:                assertEquals(query.getParameters().getOrderedNames().get(13),
1275:                        "propertyShortObject");
1276:                assertEquals(query.getParameters().getOrderedNames().get(14),
1277:                        "propertyString");
1278:                assertEquals(query.getParameters().getOrderedNames().get(15),
1279:                        "propertyTime");
1280:                assertTrue(Arrays.equals(query.getParameters()
1281:                        .getOrderedNamesArray(), new String[] {
1282:                        "propertyBigDecimal", "propertyBooleanObject",
1283:                        "propertyByteObject", "propertyCalendar",
1284:                        "propertyCharacterObject", "propertyDate",
1285:                        "propertyDoubleObject", "propertyEnum",
1286:                        "propertyFloat", "propertyFloatObject",
1287:                        "propertyIntegerObject", "propertyLongObject",
1288:                        "propertyShort", "propertyShortObject",
1289:                        "propertyString", "propertyTime" }));
1290:
1291:                assertTrue(execute(query, new DbPreparedStatementHandler() {
1292:                    public void setParameters(DbPreparedStatement statement) {
1293:                        Calendar cal = Calendar.getInstance();
1294:                        cal.set(2002, 5, 18, 15, 26, 14);
1295:                        cal.set(Calendar.MILLISECOND, 764);
1296:                        statement.setBigDecimal(1,
1297:                                new BigDecimal("219038743.392874")).setBoolean(
1298:                                2, false).setByte(3, (byte) 34)
1299:                                .setTimestamp(
1300:                                        4,
1301:                                        new java.sql.Timestamp(cal.getTime()
1302:                                                .getTime())).setString(5, "r")
1303:                                .setTimestamp(
1304:                                        6,
1305:                                        new java.sql.Timestamp(cal.getTime()
1306:                                                .getTime())).setDouble(7,
1307:                                        143298.692d)
1308:                                .setString(8, "VALUE_THREE").setDouble(9,
1309:                                        98634.2d).setDouble(10, 8734.7d)
1310:                                .setInt(11, 968).setLong(12, 66875L).setShort(
1311:                                        13, (short) 43)
1312:                                .setShort(14, (short) 68).setString(15,
1313:                                        "someotherstring").setTime(16,
1314:                                        new Time(15, 26, 14));
1315:                    }
1316:                }));
1317:            }
1318:
1319:            public void testSubselectParamsMckoi() {
1320:                // mxkoi doesn't support subqueries as update values
1321:            }
1322:
1323:            public void testCloneMckoi() {
1324:                Select wherequery = new Select(mMckoi);
1325:                wherequery.from("table2").field("max(propertyShort)")
1326:                        .whereParameter("propertyShort", "!=");
1327:
1328:                final Calendar cal = Calendar.getInstance();
1329:                cal.set(2002, 7, 19, 12, 17, 52);
1330:                cal.set(Calendar.MILLISECOND, 462);
1331:                Update query = new Update(mMckoi);
1332:                query.table("tablename").fieldParameter("nullColumn")
1333:                        .field("propertyBigDecimal",
1334:                                new BigDecimal("98347.876438637"))
1335:                        .fieldParameter("propertyBoolean").fieldParameter(
1336:                                "propertyByte").field("propertyCalendar",
1337:                                cal.getTime()).fieldParameter("propertyChar")
1338:                        .field("propertyDate", cal).field("propertyDouble",
1339:                                12.3d).fieldParameter("propertyFloat")
1340:                        .fieldParameter("propertyInt").field("propertyShort",
1341:                                (short) 12).fieldParameter("propertySqlDate")
1342:                        .fieldParameter("propertyString").field(
1343:                                "propertyStringbuffer",
1344:                                new StringBuffer("stringbuffer'value")).field(
1345:                                "propertyTime",
1346:                                new Time(cal.getTime().getTime()))
1347:                        .fieldParameter("propertyTimestamp").where(
1348:                                "tablename.propertyShort >= (" + wherequery
1349:                                        + ")").whereSubselect(wherequery)
1350:                        .whereParameterOr("tablename.propertyString",
1351:                                "propertyString", "=").whereOr(
1352:                                "tablename.propertyByte", "=", (byte) 54)
1353:                        .whereAnd("tablename.propertyDouble", "!=", 73453.71d)
1354:                        .whereParameterOr("tablename.propertyInt",
1355:                                "propertyInt", "=").whereParameterAnd(
1356:                                "tablename.propertyLong", "propertyLong", "<")
1357:                        .whereParameterOr("tablename.propertyChar",
1358:                                "propertyChar", "=");
1359:
1360:                Update query_clone = query.clone();
1361:                assertEquals(query.getSql(), query_clone.getSql());
1362:                assertTrue(query != query_clone);
1363:                execute(query, new DbPreparedStatementHandler() {
1364:                    public void setParameters(DbPreparedStatement statement) {
1365:                        statement.setString("nullColumn", null).setBoolean(
1366:                                "propertyBoolean", true).setByte(
1367:                                "propertyByte", (byte) 16).setString(
1368:                                "propertyChar", "M").setFloat("propertyFloat",
1369:                                13.4f).setInt("propertyInt", 34).setDate(
1370:                                "propertySqlDate",
1371:                                new java.sql.Date(cal.getTime().getTime()))
1372:                                .setString("propertyString", "string'value")
1373:                                .setTimestamp("propertyTimestamp",
1374:                                        new Timestamp(cal.getTime().getTime()))
1375:                                .setShort("propertyShort", (short) 4).setLong(
1376:                                        "propertyLong", 34543);
1377:                    }
1378:                });
1379:            }
1380:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.