1 package org.campware.cream.om; 2 3 import java.math.BigDecimal ; 4 import java.sql.Connection ; 5 import java.sql.SQLException ; 6 import java.util.ArrayList ; 7 import java.util.Date ; 8 import java.util.Iterator ; 9 import java.util.LinkedList ; 10 import java.util.List ; 11 12 import org.apache.torque.NoRowsException; 13 import org.apache.torque.TooManyRowsException; 14 import org.apache.torque.Torque; 15 import org.apache.torque.TorqueException; 16 import org.apache.torque.map.MapBuilder; 17 import org.apache.torque.map.TableMap; 18 import org.apache.torque.om.DateKey; 19 import org.apache.torque.om.NumberKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.ObjectKey; 22 import org.apache.torque.om.SimpleKey; 23 import org.apache.torque.util.BasePeer; 24 import org.apache.torque.util.Criteria; 25 26 import com.workingdogs.village.DataSetException; 27 import com.workingdogs.village.QueryDataSet; 28 import com.workingdogs.village.Record; 29 30 import org.campware.cream.om.map.*; 32 33 34 35 36 37 38 39 40 46 public abstract class BaseCustomerPeer 47 extends BasePeer 48 { 49 50 51 public static final String DATABASE_NAME = "cream"; 52 53 54 public static final String TABLE_NAME = "CUSTOMER"; 55 56 61 public static MapBuilder getMapBuilder() 62 throws TorqueException 63 { 64 return getMapBuilder(CustomerMapBuilder.CLASS_NAME); 65 } 66 67 68 public static final String CUSTOMER_ID; 69 70 public static final String CUSTOMER_CODE; 71 72 public static final String STATUS; 73 74 public static final String PRIORITY; 75 76 public static final String CUSTOMER_TYPE; 77 78 public static final String CUSTOMER_CAT_ID; 79 80 public static final String CUSTOMER_NAME_1; 81 82 public static final String CUSTOMER_NAME_2; 83 84 public static final String CUSTOMER_DISPLAY; 85 86 public static final String DEAR; 87 88 public static final String ADDRESS_1; 89 90 public static final String ADDRESS_2; 91 92 public static final String CITY; 93 94 public static final String ZIP; 95 96 public static final String STATE; 97 98 public static final String COUNTRY_ID; 99 100 public static final String REGION_ID; 101 102 public static final String PHONE_1; 103 104 public static final String PHONE_2; 105 106 public static final String FAX; 107 108 public static final String EMAIL; 109 110 public static final String EMAIL_FORMAT; 111 112 public static final String SEND_NEWS; 113 114 public static final String WEB_URL; 115 116 public static final String LANGUAGE_ID; 117 118 public static final String GENDER; 119 120 public static final String EDUCATION_CAT_ID; 121 122 public static final String HOUSEHOLD_CAT_ID; 123 124 public static final String CUSTOM_1; 125 126 public static final String CUSTOM_2; 127 128 public static final String CUSTOM_3; 129 130 public static final String CUSTOM_4; 131 132 public static final String CUSTOM_5; 133 134 public static final String CUSTOM_6; 135 136 public static final String NOTES; 137 138 public static final String CREATED; 139 140 public static final String MODIFIED; 141 142 public static final String CREATED_BY; 143 144 public static final String MODIFIED_BY; 145 146 static 147 { 148 CUSTOMER_ID = "CUSTOMER.CUSTOMER_ID"; 149 CUSTOMER_CODE = "CUSTOMER.CUSTOMER_CODE"; 150 STATUS = "CUSTOMER.STATUS"; 151 PRIORITY = "CUSTOMER.PRIORITY"; 152 CUSTOMER_TYPE = "CUSTOMER.CUSTOMER_TYPE"; 153 CUSTOMER_CAT_ID = "CUSTOMER.CUSTOMER_CAT_ID"; 154 CUSTOMER_NAME_1 = "CUSTOMER.CUSTOMER_NAME_1"; 155 CUSTOMER_NAME_2 = "CUSTOMER.CUSTOMER_NAME_2"; 156 CUSTOMER_DISPLAY = "CUSTOMER.CUSTOMER_DISPLAY"; 157 DEAR = "CUSTOMER.DEAR"; 158 ADDRESS_1 = "CUSTOMER.ADDRESS_1"; 159 ADDRESS_2 = "CUSTOMER.ADDRESS_2"; 160 CITY = "CUSTOMER.CITY"; 161 ZIP = "CUSTOMER.ZIP"; 162 STATE = "CUSTOMER.STATE"; 163 COUNTRY_ID = "CUSTOMER.COUNTRY_ID"; 164 REGION_ID = "CUSTOMER.REGION_ID"; 165 PHONE_1 = "CUSTOMER.PHONE_1"; 166 PHONE_2 = "CUSTOMER.PHONE_2"; 167 FAX = "CUSTOMER.FAX"; 168 EMAIL = "CUSTOMER.EMAIL"; 169 EMAIL_FORMAT = "CUSTOMER.EMAIL_FORMAT"; 170 SEND_NEWS = "CUSTOMER.SEND_NEWS"; 171 WEB_URL = "CUSTOMER.WEB_URL"; 172 LANGUAGE_ID = "CUSTOMER.LANGUAGE_ID"; 173 GENDER = "CUSTOMER.GENDER"; 174 EDUCATION_CAT_ID = "CUSTOMER.EDUCATION_CAT_ID"; 175 HOUSEHOLD_CAT_ID = "CUSTOMER.HOUSEHOLD_CAT_ID"; 176 CUSTOM_1 = "CUSTOMER.CUSTOM_1"; 177 CUSTOM_2 = "CUSTOMER.CUSTOM_2"; 178 CUSTOM_3 = "CUSTOMER.CUSTOM_3"; 179 CUSTOM_4 = "CUSTOMER.CUSTOM_4"; 180 CUSTOM_5 = "CUSTOMER.CUSTOM_5"; 181 CUSTOM_6 = "CUSTOMER.CUSTOM_6"; 182 NOTES = "CUSTOMER.NOTES"; 183 CREATED = "CUSTOMER.CREATED"; 184 MODIFIED = "CUSTOMER.MODIFIED"; 185 CREATED_BY = "CUSTOMER.CREATED_BY"; 186 MODIFIED_BY = "CUSTOMER.MODIFIED_BY"; 187 if (Torque.isInit()) 188 { 189 try 190 { 191 getMapBuilder(CustomerMapBuilder.CLASS_NAME); 192 } 193 catch (Exception e) 194 { 195 log.error("Could not initialize Peer", e); 196 } 197 } 198 else 199 { 200 Torque.registerMapBuilder(CustomerMapBuilder.CLASS_NAME); 201 } 202 } 203 204 205 public static final int numColumns = 39; 206 207 208 protected static final String CLASSNAME_DEFAULT = 209 "org.campware.cream.om.Customer"; 210 211 212 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 213 214 220 private static Class initClass(String className) 221 { 222 Class c = null; 223 try 224 { 225 c = Class.forName(className); 226 } 227 catch (Throwable t) 228 { 229 log.error("A FATAL ERROR has occurred which should not " 230 + "have happened under any circumstance. Please notify " 231 + "the Torque developers <torque-dev@db.apache.org> " 232 + "and give as many details as possible (including the error " 233 + "stack trace).", t); 234 235 if (t instanceof Error ) 237 { 238 throw (Error ) t.fillInStackTrace(); 239 } 240 } 241 return c; 242 } 243 244 254 public static List resultSet2Objects(java.sql.ResultSet results) 255 throws TorqueException 256 { 257 try 258 { 259 QueryDataSet qds = null; 260 List rows = null; 261 try 262 { 263 qds = new QueryDataSet(results); 264 rows = getSelectResults(qds); 265 } 266 finally 267 { 268 if (qds != null) 269 { 270 qds.close(); 271 } 272 } 273 274 return populateObjects(rows); 275 } 276 catch (SQLException e) 277 { 278 throw new TorqueException(e); 279 } 280 catch (DataSetException e) 281 { 282 throw new TorqueException(e); 283 } 284 } 285 286 287 288 295 public static ObjectKey doInsert(Criteria criteria) 296 throws TorqueException 297 { 298 return BaseCustomerPeer 299 .doInsert(criteria, (Connection ) null); 300 } 301 302 312 public static ObjectKey doInsert(Criteria criteria, Connection con) 313 throws TorqueException 314 { 315 316 setDbName(criteria); 317 318 if (con == null) 319 { 320 return BasePeer.doInsert(criteria); 321 } 322 else 323 { 324 return BasePeer.doInsert(criteria, con); 325 } 326 } 327 328 335 public static void addSelectColumns(Criteria criteria) 336 throws TorqueException 337 { 338 criteria.addSelectColumn(CUSTOMER_ID); 339 criteria.addSelectColumn(CUSTOMER_CODE); 340 criteria.addSelectColumn(STATUS); 341 criteria.addSelectColumn(PRIORITY); 342 criteria.addSelectColumn(CUSTOMER_TYPE); 343 criteria.addSelectColumn(CUSTOMER_CAT_ID); 344 criteria.addSelectColumn(CUSTOMER_NAME_1); 345 criteria.addSelectColumn(CUSTOMER_NAME_2); 346 criteria.addSelectColumn(CUSTOMER_DISPLAY); 347 criteria.addSelectColumn(DEAR); 348 criteria.addSelectColumn(ADDRESS_1); 349 criteria.addSelectColumn(ADDRESS_2); 350 criteria.addSelectColumn(CITY); 351 criteria.addSelectColumn(ZIP); 352 criteria.addSelectColumn(STATE); 353 criteria.addSelectColumn(COUNTRY_ID); 354 criteria.addSelectColumn(REGION_ID); 355 criteria.addSelectColumn(PHONE_1); 356 criteria.addSelectColumn(PHONE_2); 357 criteria.addSelectColumn(FAX); 358 criteria.addSelectColumn(EMAIL); 359 criteria.addSelectColumn(EMAIL_FORMAT); 360 criteria.addSelectColumn(SEND_NEWS); 361 criteria.addSelectColumn(WEB_URL); 362 criteria.addSelectColumn(LANGUAGE_ID); 363 criteria.addSelectColumn(GENDER); 364 criteria.addSelectColumn(EDUCATION_CAT_ID); 365 criteria.addSelectColumn(HOUSEHOLD_CAT_ID); 366 criteria.addSelectColumn(CUSTOM_1); 367 criteria.addSelectColumn(CUSTOM_2); 368 criteria.addSelectColumn(CUSTOM_3); 369 criteria.addSelectColumn(CUSTOM_4); 370 criteria.addSelectColumn(CUSTOM_5); 371 criteria.addSelectColumn(CUSTOM_6); 372 criteria.addSelectColumn(NOTES); 373 criteria.addSelectColumn(CREATED); 374 criteria.addSelectColumn(MODIFIED); 375 criteria.addSelectColumn(CREATED_BY); 376 criteria.addSelectColumn(MODIFIED_BY); 377 } 378 379 388 public static Customer row2Object(Record row, 389 int offset, 390 Class cls) 391 throws TorqueException 392 { 393 try 394 { 395 Customer obj = (Customer) cls.newInstance(); 396 CustomerPeer.populateObject(row, offset, obj); 397 obj.setModified(false); 398 obj.setNew(false); 399 400 return obj; 401 } 402 catch (InstantiationException e) 403 { 404 throw new TorqueException(e); 405 } 406 catch (IllegalAccessException e) 407 { 408 throw new TorqueException(e); 409 } 410 } 411 412 421 public static void populateObject(Record row, 422 int offset, 423 Customer obj) 424 throws TorqueException 425 { 426 try 427 { 428 obj.setCustomerId(row.getValue(offset + 0).asInt()); 429 obj.setCustomerCode(row.getValue(offset + 1).asString()); 430 obj.setStatus(row.getValue(offset + 2).asInt()); 431 obj.setPriority(row.getValue(offset + 3).asInt()); 432 obj.setCustomerType(row.getValue(offset + 4).asInt()); 433 obj.setCustomerCatId(row.getValue(offset + 5).asInt()); 434 obj.setCustomerName1(row.getValue(offset + 6).asString()); 435 obj.setCustomerName2(row.getValue(offset + 7).asString()); 436 obj.setCustomerDisplay(row.getValue(offset + 8).asString()); 437 obj.setDear(row.getValue(offset + 9).asString()); 438 obj.setAddress1(row.getValue(offset + 10).asString()); 439 obj.setAddress2(row.getValue(offset + 11).asString()); 440 obj.setCity(row.getValue(offset + 12).asString()); 441 obj.setZip(row.getValue(offset + 13).asString()); 442 obj.setState(row.getValue(offset + 14).asString()); 443 obj.setCountryId(row.getValue(offset + 15).asInt()); 444 obj.setRegionId(row.getValue(offset + 16).asInt()); 445 obj.setPhone1(row.getValue(offset + 17).asString()); 446 obj.setPhone2(row.getValue(offset + 18).asString()); 447 obj.setFax(row.getValue(offset + 19).asString()); 448 obj.setEmail(row.getValue(offset + 20).asString()); 449 obj.setEmailFormat(row.getValue(offset + 21).asInt()); 450 obj.setSendNews(row.getValue(offset + 22).asInt()); 451 obj.setWebUrl(row.getValue(offset + 23).asString()); 452 obj.setLanguageId(row.getValue(offset + 24).asInt()); 453 obj.setGender(row.getValue(offset + 25).asInt()); 454 obj.setEducationCatId(row.getValue(offset + 26).asInt()); 455 obj.setHouseholdCatId(row.getValue(offset + 27).asInt()); 456 obj.setCustom1(row.getValue(offset + 28).asString()); 457 obj.setCustom2(row.getValue(offset + 29).asString()); 458 obj.setCustom3(row.getValue(offset + 30).asString()); 459 obj.setCustom4(row.getValue(offset + 31).asString()); 460 obj.setCustom5(row.getValue(offset + 32).asString()); 461 obj.setCustom6(row.getValue(offset + 33).asString()); 462 obj.setNotes(row.getValue(offset + 34).asString()); 463 obj.setCreated(row.getValue(offset + 35).asUtilDate()); 464 obj.setModified(row.getValue(offset + 36).asUtilDate()); 465 obj.setCreatedBy(row.getValue(offset + 37).asString()); 466 obj.setModifiedBy(row.getValue(offset + 38).asString()); 467 } 468 catch (DataSetException e) 469 { 470 throw new TorqueException(e); 471 } 472 } 473 474 482 public static List doSelect(Criteria criteria) throws TorqueException 483 { 484 return populateObjects(doSelectVillageRecords(criteria)); 485 } 486 487 496 public static List doSelect(Criteria criteria, Connection con) 497 throws TorqueException 498 { 499 return populateObjects(doSelectVillageRecords(criteria, con)); 500 } 501 502 512 public static List doSelectVillageRecords(Criteria criteria) 513 throws TorqueException 514 { 515 return BaseCustomerPeer 516 .doSelectVillageRecords(criteria, (Connection ) null); 517 } 518 519 528 public static List doSelectVillageRecords(Criteria criteria, Connection con) 529 throws TorqueException 530 { 531 if (criteria.getSelectColumns().size() == 0) 532 { 533 addSelectColumns(criteria); 534 } 535 536 537 setDbName(criteria); 538 539 if (con == null) 542 { 543 return BasePeer.doSelect(criteria); 544 } 545 else 546 { 547 return BasePeer.doSelect(criteria, con); 548 } 549 } 550 551 558 public static List populateObjects(List records) 559 throws TorqueException 560 { 561 List results = new ArrayList (records.size()); 562 563 for (int i = 0; i < records.size(); i++) 565 { 566 Record row = (Record) records.get(i); 567 results.add(CustomerPeer.row2Object(row, 1, 568 CustomerPeer.getOMClass())); 569 } 570 return results; 571 } 572 573 574 582 public static Class getOMClass() 583 throws TorqueException 584 { 585 return CLASS_DEFAULT; 586 } 587 588 596 public static void doUpdate(Criteria criteria) throws TorqueException 597 { 598 BaseCustomerPeer 599 .doUpdate(criteria, (Connection ) null); 600 } 601 602 613 public static void doUpdate(Criteria criteria, Connection con) 614 throws TorqueException 615 { 616 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 617 selectCriteria.put(CUSTOMER_ID, criteria.remove(CUSTOMER_ID)); 618 619 setDbName(criteria); 620 621 if (con == null) 622 { 623 BasePeer.doUpdate(selectCriteria, criteria); 624 } 625 else 626 { 627 BasePeer.doUpdate(selectCriteria, criteria, con); 628 } 629 } 630 631 638 public static void doDelete(Criteria criteria) throws TorqueException 639 { 640 CustomerPeer 641 .doDelete(criteria, (Connection ) null); 642 } 643 644 654 public static void doDelete(Criteria criteria, Connection con) 655 throws TorqueException 656 { 657 658 setDbName(criteria); 659 660 if (con == null) 661 { 662 BasePeer.doDelete(criteria); 663 } 664 else 665 { 666 BasePeer.doDelete(criteria, con); 667 } 668 } 669 670 676 public static List doSelect(Customer obj) throws TorqueException 677 { 678 return doSelect(buildSelectCriteria(obj)); 679 } 680 681 687 public static void doInsert(Customer obj) throws TorqueException 688 { 689 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 690 obj.setNew(false); 691 obj.setModified(false); 692 } 693 694 699 public static void doUpdate(Customer obj) throws TorqueException 700 { 701 doUpdate(buildCriteria(obj)); 702 obj.setModified(false); 703 } 704 705 710 public static void doDelete(Customer obj) throws TorqueException 711 { 712 doDelete(buildSelectCriteria(obj)); 713 } 714 715 725 public static void doInsert(Customer obj, Connection con) 726 throws TorqueException 727 { 728 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 729 obj.setNew(false); 730 obj.setModified(false); 731 } 732 733 743 public static void doUpdate(Customer obj, Connection con) 744 throws TorqueException 745 { 746 doUpdate(buildCriteria(obj), con); 747 obj.setModified(false); 748 } 749 750 760 public static void doDelete(Customer obj, Connection con) 761 throws TorqueException 762 { 763 doDelete(buildSelectCriteria(obj), con); 764 } 765 766 773 public static void doDelete(ObjectKey pk) throws TorqueException 774 { 775 BaseCustomerPeer 776 .doDelete(pk, (Connection ) null); 777 } 778 779 789 public static void doDelete(ObjectKey pk, Connection con) 790 throws TorqueException 791 { 792 doDelete(buildCriteria(pk), con); 793 } 794 795 796 public static Criteria buildCriteria( ObjectKey pk ) 797 { 798 Criteria criteria = new Criteria(); 799 criteria.add(CUSTOMER_ID, pk); 800 return criteria; 801 } 802 803 804 public static Criteria buildCriteria( Customer obj ) 805 { 806 Criteria criteria = new Criteria(DATABASE_NAME); 807 if (!obj.isNew()) 808 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 809 criteria.add(CUSTOMER_CODE, obj.getCustomerCode()); 810 criteria.add(STATUS, obj.getStatus()); 811 criteria.add(PRIORITY, obj.getPriority()); 812 criteria.add(CUSTOMER_TYPE, obj.getCustomerType()); 813 criteria.add(CUSTOMER_CAT_ID, obj.getCustomerCatId()); 814 criteria.add(CUSTOMER_NAME_1, obj.getCustomerName1()); 815 criteria.add(CUSTOMER_NAME_2, obj.getCustomerName2()); 816 criteria.add(CUSTOMER_DISPLAY, obj.getCustomerDisplay()); 817 criteria.add(DEAR, obj.getDear()); 818 criteria.add(ADDRESS_1, obj.getAddress1()); 819 criteria.add(ADDRESS_2, obj.getAddress2()); 820 criteria.add(CITY, obj.getCity()); 821 criteria.add(ZIP, obj.getZip()); 822 criteria.add(STATE, obj.getState()); 823 criteria.add(COUNTRY_ID, obj.getCountryId()); 824 criteria.add(REGION_ID, obj.getRegionId()); 825 criteria.add(PHONE_1, obj.getPhone1()); 826 criteria.add(PHONE_2, obj.getPhone2()); 827 criteria.add(FAX, obj.getFax()); 828 criteria.add(EMAIL, obj.getEmail()); 829 criteria.add(EMAIL_FORMAT, obj.getEmailFormat()); 830 criteria.add(SEND_NEWS, obj.getSendNews()); 831 criteria.add(WEB_URL, obj.getWebUrl()); 832 criteria.add(LANGUAGE_ID, obj.getLanguageId()); 833 criteria.add(GENDER, obj.getGender()); 834 criteria.add(EDUCATION_CAT_ID, obj.getEducationCatId()); 835 criteria.add(HOUSEHOLD_CAT_ID, obj.getHouseholdCatId()); 836 criteria.add(CUSTOM_1, obj.getCustom1()); 837 criteria.add(CUSTOM_2, obj.getCustom2()); 838 criteria.add(CUSTOM_3, obj.getCustom3()); 839 criteria.add(CUSTOM_4, obj.getCustom4()); 840 criteria.add(CUSTOM_5, obj.getCustom5()); 841 criteria.add(CUSTOM_6, obj.getCustom6()); 842 criteria.add(NOTES, obj.getNotes()); 843 criteria.add(CREATED, obj.getCreated()); 844 criteria.add(MODIFIED, obj.getModified()); 845 criteria.add(CREATED_BY, obj.getCreatedBy()); 846 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 847 return criteria; 848 } 849 850 851 public static Criteria buildSelectCriteria( Customer obj ) 852 { 853 Criteria criteria = new Criteria(DATABASE_NAME); 854 if (!obj.isNew()) 855 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 856 criteria.add(CUSTOMER_CODE, obj.getCustomerCode()); 857 criteria.add(STATUS, obj.getStatus()); 858 criteria.add(PRIORITY, obj.getPriority()); 859 criteria.add(CUSTOMER_TYPE, obj.getCustomerType()); 860 criteria.add(CUSTOMER_CAT_ID, obj.getCustomerCatId()); 861 criteria.add(CUSTOMER_NAME_1, obj.getCustomerName1()); 862 criteria.add(CUSTOMER_NAME_2, obj.getCustomerName2()); 863 criteria.add(CUSTOMER_DISPLAY, obj.getCustomerDisplay()); 864 criteria.add(DEAR, obj.getDear()); 865 criteria.add(ADDRESS_1, obj.getAddress1()); 866 criteria.add(ADDRESS_2, obj.getAddress2()); 867 criteria.add(CITY, obj.getCity()); 868 criteria.add(ZIP, obj.getZip()); 869 criteria.add(STATE, obj.getState()); 870 criteria.add(COUNTRY_ID, obj.getCountryId()); 871 criteria.add(REGION_ID, obj.getRegionId()); 872 criteria.add(PHONE_1, obj.getPhone1()); 873 criteria.add(PHONE_2, obj.getPhone2()); 874 criteria.add(FAX, obj.getFax()); 875 criteria.add(EMAIL, obj.getEmail()); 876 criteria.add(EMAIL_FORMAT, obj.getEmailFormat()); 877 criteria.add(SEND_NEWS, obj.getSendNews()); 878 criteria.add(WEB_URL, obj.getWebUrl()); 879 criteria.add(LANGUAGE_ID, obj.getLanguageId()); 880 criteria.add(GENDER, obj.getGender()); 881 criteria.add(EDUCATION_CAT_ID, obj.getEducationCatId()); 882 criteria.add(HOUSEHOLD_CAT_ID, obj.getHouseholdCatId()); 883 criteria.add(CUSTOM_1, obj.getCustom1()); 884 criteria.add(CUSTOM_2, obj.getCustom2()); 885 criteria.add(CUSTOM_3, obj.getCustom3()); 886 criteria.add(CUSTOM_4, obj.getCustom4()); 887 criteria.add(CUSTOM_5, obj.getCustom5()); 888 criteria.add(CUSTOM_6, obj.getCustom6()); 889 criteria.add(NOTES, obj.getNotes()); 890 criteria.add(CREATED, obj.getCreated()); 891 criteria.add(MODIFIED, obj.getModified()); 892 criteria.add(CREATED_BY, obj.getCreatedBy()); 893 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 894 return criteria; 895 } 896 897 898 907 public static Customer retrieveByPK(int pk) 908 throws TorqueException, NoRowsException, TooManyRowsException 909 { 910 return retrieveByPK(SimpleKey.keyFor(pk)); 911 } 912 913 923 public static Customer retrieveByPK(int pk, Connection con) 924 throws TorqueException, NoRowsException, TooManyRowsException 925 { 926 return retrieveByPK(SimpleKey.keyFor(pk), con); 927 } 928 929 938 public static Customer retrieveByPK(ObjectKey pk) 939 throws TorqueException, NoRowsException, TooManyRowsException 940 { 941 Connection db = null; 942 Customer retVal = null; 943 try 944 { 945 db = Torque.getConnection(DATABASE_NAME); 946 retVal = retrieveByPK(pk, db); 947 } 948 finally 949 { 950 Torque.closeConnection(db); 951 } 952 return(retVal); 953 } 954 955 965 public static Customer retrieveByPK(ObjectKey pk, Connection con) 966 throws TorqueException, NoRowsException, TooManyRowsException 967 { 968 Criteria criteria = buildCriteria(pk); 969 List v = doSelect(criteria, con); 970 if (v.size() == 0) 971 { 972 throw new NoRowsException("Failed to select a row."); 973 } 974 else if (v.size() > 1) 975 { 976 throw new TooManyRowsException("Failed to select only one row."); 977 } 978 else 979 { 980 return (Customer)v.get(0); 981 } 982 } 983 984 991 public static List retrieveByPKs(List pks) 992 throws TorqueException 993 { 994 Connection db = null; 995 List retVal = null; 996 try 997 { 998 db = Torque.getConnection(DATABASE_NAME); 999 retVal = retrieveByPKs(pks, db); 1000 } 1001 finally 1002 { 1003 Torque.closeConnection(db); 1004 } 1005 return(retVal); 1006 } 1007 1008 1016 public static List retrieveByPKs( List pks, Connection dbcon ) 1017 throws TorqueException 1018 { 1019 List objs = null; 1020 if (pks == null || pks.size() == 0) 1021 { 1022 objs = new LinkedList (); 1023 } 1024 else 1025 { 1026 Criteria criteria = new Criteria(); 1027 criteria.addIn( CUSTOMER_ID, pks ); 1028 objs = doSelect(criteria, dbcon); 1029 } 1030 return objs; 1031 } 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1053 protected static List doSelectJoinCustomerCategory(Criteria criteria) 1054 throws TorqueException 1055 { 1056 setDbName(criteria); 1057 1058 CustomerPeer.addSelectColumns(criteria); 1059 int offset = numColumns + 1; 1060 CustomerCategoryPeer.addSelectColumns(criteria); 1061 1062 1063 criteria.addJoin(CustomerPeer.CUSTOMER_CAT_ID, 1064 CustomerCategoryPeer.CUSTOMER_CAT_ID); 1065 1066 1067 1068 List rows = BasePeer.doSelect(criteria); 1069 List results = new ArrayList (); 1070 1071 for (int i = 0; i < rows.size(); i++) 1072 { 1073 Record row = (Record) rows.get(i); 1074 1075 Class omClass = CustomerPeer.getOMClass(); 1076 Customer obj1 = (Customer) CustomerPeer 1077 .row2Object(row, 1, omClass); 1078 omClass = CustomerCategoryPeer.getOMClass(); 1079 CustomerCategory obj2 = (CustomerCategory)CustomerCategoryPeer 1080 .row2Object(row, offset, omClass); 1081 1082 boolean newObject = true; 1083 for (int j = 0; j < results.size(); j++) 1084 { 1085 Customer temp_obj1 = (Customer)results.get(j); 1086 CustomerCategory temp_obj2 = (CustomerCategory)temp_obj1.getCustomerCategory(); 1087 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1088 { 1089 newObject = false; 1090 temp_obj2.addCustomer(obj1); 1091 break; 1092 } 1093 } 1094 if (newObject) 1095 { 1096 obj2.initCustomers(); 1097 obj2.addCustomer(obj1); 1098 } 1099 results.add(obj1); 1100 } 1101 return results; 1102 } 1103 1104 1105 1106 1107 1118 protected static List doSelectJoinCountry(Criteria criteria) 1119 throws TorqueException 1120 { 1121 setDbName(criteria); 1122 1123 CustomerPeer.addSelectColumns(criteria); 1124 int offset = numColumns + 1; 1125 CountryPeer.addSelectColumns(criteria); 1126 1127 1128 criteria.addJoin(CustomerPeer.COUNTRY_ID, 1129 CountryPeer.COUNTRY_ID); 1130 1131 1132 1133 List rows = BasePeer.doSelect(criteria); 1134 List results = new ArrayList (); 1135 1136 for (int i = 0; i < rows.size(); i++) 1137 { 1138 Record row = (Record) rows.get(i); 1139 1140 Class omClass = CustomerPeer.getOMClass(); 1141 Customer obj1 = (Customer) CustomerPeer 1142 .row2Object(row, 1, omClass); 1143 omClass = CountryPeer.getOMClass(); 1144 Country obj2 = (Country)CountryPeer 1145 .row2Object(row, offset, omClass); 1146 1147 boolean newObject = true; 1148 for (int j = 0; j < results.size(); j++) 1149 { 1150 Customer temp_obj1 = (Customer)results.get(j); 1151 Country temp_obj2 = (Country)temp_obj1.getCountry(); 1152 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1153 { 1154 newObject = false; 1155 temp_obj2.addCustomer(obj1); 1156 break; 1157 } 1158 } 1159 if (newObject) 1160 { 1161 obj2.initCustomers(); 1162 obj2.addCustomer(obj1); 1163 } 1164 results.add(obj1); 1165 } 1166 return results; 1167 } 1168 1169 1170 1171 1172 1183 protected static List doSelectJoinRegion(Criteria criteria) 1184 throws TorqueException 1185 { 1186 setDbName(criteria); 1187 1188 CustomerPeer.addSelectColumns(criteria); 1189 int offset = numColumns + 1; 1190 RegionPeer.addSelectColumns(criteria); 1191 1192 1193 criteria.addJoin(CustomerPeer.REGION_ID, 1194 RegionPeer.REGION_ID); 1195 1196 1197 1198 List rows = BasePeer.doSelect(criteria); 1199 List results = new ArrayList (); 1200 1201 for (int i = 0; i < rows.size(); i++) 1202 { 1203 Record row = (Record) rows.get(i); 1204 1205 Class omClass = CustomerPeer.getOMClass(); 1206 Customer obj1 = (Customer) CustomerPeer 1207 .row2Object(row, 1, omClass); 1208 omClass = RegionPeer.getOMClass(); 1209 Region obj2 = (Region)RegionPeer 1210 .row2Object(row, offset, omClass); 1211 1212 boolean newObject = true; 1213 for (int j = 0; j < results.size(); j++) 1214 { 1215 Customer temp_obj1 = (Customer)results.get(j); 1216 Region temp_obj2 = (Region)temp_obj1.getRegion(); 1217 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1218 { 1219 newObject = false; 1220 temp_obj2.addCustomer(obj1); 1221 break; 1222 } 1223 } 1224 if (newObject) 1225 { 1226 obj2.initCustomers(); 1227 obj2.addCustomer(obj1); 1228 } 1229 results.add(obj1); 1230 } 1231 return results; 1232 } 1233 1234 1235 1236 1237 1248 protected static List doSelectJoinLanguage(Criteria criteria) 1249 throws TorqueException 1250 { 1251 setDbName(criteria); 1252 1253 CustomerPeer.addSelectColumns(criteria); 1254 int offset = numColumns + 1; 1255 LanguagePeer.addSelectColumns(criteria); 1256 1257 1258 criteria.addJoin(CustomerPeer.LANGUAGE_ID, 1259 LanguagePeer.LANGUAGE_ID); 1260 1261 1262 1263 List rows = BasePeer.doSelect(criteria); 1264 List results = new ArrayList (); 1265 1266 for (int i = 0; i < rows.size(); i++) 1267 { 1268 Record row = (Record) rows.get(i); 1269 1270 Class omClass = CustomerPeer.getOMClass(); 1271 Customer obj1 = (Customer) CustomerPeer 1272 .row2Object(row, 1, omClass); 1273 omClass = LanguagePeer.getOMClass(); 1274 Language obj2 = (Language)LanguagePeer 1275 .row2Object(row, offset, omClass); 1276 1277 boolean newObject = true; 1278 for (int j = 0; j < results.size(); j++) 1279 { 1280 Customer temp_obj1 = (Customer)results.get(j); 1281 Language temp_obj2 = (Language)temp_obj1.getLanguage(); 1282 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1283 { 1284 newObject = false; 1285 temp_obj2.addCustomer(obj1); 1286 break; 1287 } 1288 } 1289 if (newObject) 1290 { 1291 obj2.initCustomers(); 1292 obj2.addCustomer(obj1); 1293 } 1294 results.add(obj1); 1295 } 1296 return results; 1297 } 1298 1299 1300 1301 1302 1313 protected static List doSelectJoinEducationCategory(Criteria criteria) 1314 throws TorqueException 1315 { 1316 setDbName(criteria); 1317 1318 CustomerPeer.addSelectColumns(criteria); 1319 int offset = numColumns + 1; 1320 EducationCategoryPeer.addSelectColumns(criteria); 1321 1322 1323 criteria.addJoin(CustomerPeer.EDUCATION_CAT_ID, 1324 EducationCategoryPeer.EDUCATION_CAT_ID); 1325 1326 1327 1328 List rows = BasePeer.doSelect(criteria); 1329 List results = new ArrayList (); 1330 1331 for (int i = 0; i < rows.size(); i++) 1332 { 1333 Record row = (Record) rows.get(i); 1334 1335 Class omClass = CustomerPeer.getOMClass(); 1336 Customer obj1 = (Customer) CustomerPeer 1337 .row2Object(row, 1, omClass); 1338 omClass = EducationCategoryPeer.getOMClass(); 1339 EducationCategory obj2 = (EducationCategory)EducationCategoryPeer 1340 .row2Object(row, offset, omClass); 1341 1342 boolean newObject = true; 1343 for (int j = 0; j < results.size(); j++) 1344 { 1345 Customer temp_obj1 = (Customer)results.get(j); 1346 EducationCategory temp_obj2 = (EducationCategory)temp_obj1.getEducationCategory(); 1347 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1348 { 1349 newObject = false; 1350 temp_obj2.addCustomer(obj1); 1351 break; 1352 } 1353 } 1354 if (newObject) 1355 { 1356 obj2.initCustomers(); 1357 obj2.addCustomer(obj1); 1358 } 1359 results.add(obj1); 1360 } 1361 return results; 1362 } 1363 1364 1365 1366 1367 1378 protected static List doSelectJoinHouseholdCategory(Criteria criteria) 1379 throws TorqueException 1380 { 1381 setDbName(criteria); 1382 1383 CustomerPeer.addSelectColumns(criteria); 1384 int offset = numColumns + 1; 1385 HouseholdCategoryPeer.addSelectColumns(criteria); 1386 1387 1388 criteria.addJoin(CustomerPeer.HOUSEHOLD_CAT_ID, 1389 HouseholdCategoryPeer.HOUSEHOLD_CAT_ID); 1390 1391 1392 1393 List rows = BasePeer.doSelect(criteria); 1394 List results = new ArrayList (); 1395 1396 for (int i = 0; i < rows.size(); i++) 1397 { 1398 Record row = (Record) rows.get(i); 1399 1400 Class omClass = CustomerPeer.getOMClass(); 1401 Customer obj1 = (Customer) CustomerPeer 1402 .row2Object(row, 1, omClass); 1403 omClass = HouseholdCategoryPeer.getOMClass(); 1404 HouseholdCategory obj2 = (HouseholdCategory)HouseholdCategoryPeer 1405 .row2Object(row, offset, omClass); 1406 1407 boolean newObject = true; 1408 for (int j = 0; j < results.size(); j++) 1409 { 1410 Customer temp_obj1 = (Customer)results.get(j); 1411 HouseholdCategory temp_obj2 = (HouseholdCategory)temp_obj1.getHouseholdCategory(); 1412 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1413 { 1414 newObject = false; 1415 temp_obj2.addCustomer(obj1); 1416 break; 1417 } 1418 } 1419 if (newObject) 1420 { 1421 obj2.initCustomers(); 1422 obj2.addCustomer(obj1); 1423 } 1424 results.add(obj1); 1425 } 1426 return results; 1427 } 1428 1429 1430 1431 1432 1433 1434 1435 1436 1447 protected static List doSelectJoinAllExceptCustomerCategory(Criteria criteria) 1448 throws TorqueException 1449 { 1450 setDbName(criteria); 1451 1452 addSelectColumns(criteria); 1453 int offset2 = numColumns + 1; 1454 1455 1456 CountryPeer.addSelectColumns(criteria); 1457 int offset3 = offset2 + CountryPeer.numColumns; 1458 1459 RegionPeer.addSelectColumns(criteria); 1460 int offset4 = offset3 + RegionPeer.numColumns; 1461 1462 LanguagePeer.addSelectColumns(criteria); 1463 int offset5 = offset4 + LanguagePeer.numColumns; 1464 1465 EducationCategoryPeer.addSelectColumns(criteria); 1466 int offset6 = offset5 + EducationCategoryPeer.numColumns; 1467 1468 HouseholdCategoryPeer.addSelectColumns(criteria); 1469 int offset7 = offset6 + HouseholdCategoryPeer.numColumns; 1470 1471 List rows = BasePeer.doSelect(criteria); 1472 List results = new ArrayList (); 1473 1474 for (int i = 0; i < rows.size(); i++) 1475 { 1476 Record row = (Record)rows.get(i); 1477 1478 Class omClass = CustomerPeer.getOMClass(); 1479 Customer obj1 = (Customer)CustomerPeer 1480 .row2Object(row, 1, omClass); 1481 1482 1483 1484 1485 1486 omClass = CountryPeer.getOMClass(); 1487 Country obj2 = (Country)CountryPeer 1488 .row2Object( row, offset2, omClass); 1489 1490 boolean newObject = true; 1491 for (int j = 0; j < results.size(); j++) 1492 { 1493 Customer temp_obj1 = (Customer)results.get(j); 1494 Country temp_obj2 = (Country)temp_obj1.getCountry(); 1495 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1496 { 1497 newObject = false; 1498 temp_obj2.addCustomer(obj1); 1499 break; 1500 } 1501 } 1502 if (newObject) 1503 { 1504 obj2.initCustomers(); 1505 obj2.addCustomer(obj1); 1506 } 1507 1508 1509 1510 1511 omClass = RegionPeer.getOMClass(); 1512 Region obj3 = (Region)RegionPeer 1513 .row2Object( row, offset3, omClass); 1514 1515 newObject = true; 1516 for (int j = 0; j < results.size(); j++) 1517 { 1518 Customer temp_obj1 = (Customer)results.get(j); 1519 Region temp_obj3 = (Region)temp_obj1.getRegion(); 1520 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1521 { 1522 newObject = false; 1523 temp_obj3.addCustomer(obj1); 1524 break; 1525 } 1526 } 1527 if (newObject) 1528 { 1529 obj3.initCustomers(); 1530 obj3.addCustomer(obj1); 1531 } 1532 1533 1534 1535 1536 omClass = LanguagePeer.getOMClass(); 1537 Language obj4 = (Language)LanguagePeer 1538 .row2Object( row, offset4, omClass); 1539 1540 newObject = true; 1541 for (int j = 0; j < results.size(); j++) 1542 { 1543 Customer temp_obj1 = (Customer)results.get(j); 1544 Language temp_obj4 = (Language)temp_obj1.getLanguage(); 1545 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1546 { 1547 newObject = false; 1548 temp_obj4.addCustomer(obj1); 1549 break; 1550 } 1551 } 1552 if (newObject) 1553 { 1554 obj4.initCustomers(); 1555 obj4.addCustomer(obj1); 1556 } 1557 1558 1559 1560 1561 omClass = EducationCategoryPeer.getOMClass(); 1562 EducationCategory obj5 = (EducationCategory)EducationCategoryPeer 1563 .row2Object( row, offset5, omClass); 1564 1565 newObject = true; 1566 for (int j = 0; j < results.size(); j++) 1567 { 1568 Customer temp_obj1 = (Customer)results.get(j); 1569 EducationCategory temp_obj5 = (EducationCategory)temp_obj1.getEducationCategory(); 1570 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1571 { 1572 newObject = false; 1573 temp_obj5.addCustomer(obj1); 1574 break; 1575 } 1576 } 1577 if (newObject) 1578 { 1579 obj5.initCustomers(); 1580 obj5.addCustomer(obj1); 1581 } 1582 1583 1584 1585 1586 omClass = HouseholdCategoryPeer.getOMClass(); 1587 HouseholdCategory obj6 = (HouseholdCategory)HouseholdCategoryPeer 1588 .row2Object( row, offset6, omClass); 1589 1590 newObject = true; 1591 for (int j = 0; j < results.size(); j++) 1592 { 1593 Customer temp_obj1 = (Customer)results.get(j); 1594 HouseholdCategory temp_obj6 = (HouseholdCategory)temp_obj1.getHouseholdCategory(); 1595 if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) 1596 { 1597 newObject = false; 1598 temp_obj6.addCustomer(obj1); 1599 break; 1600 } 1601 } 1602 if (newObject) 1603 { 1604 obj6.initCustomers(); 1605 obj6.addCustomer(obj1); 1606 } 1607 results.add(obj1); 1608 } 1609 return results; 1610 } 1611 1612 1613 1614 1615 1616 1627 protected static List doSelectJoinAllExceptCountry(Criteria criteria) 1628 throws TorqueException 1629 { 1630 setDbName(criteria); 1631 1632 addSelectColumns(criteria); 1633 int offset2 = numColumns + 1; 1634 1635 CustomerCategoryPeer.addSelectColumns(criteria); 1636 int offset3 = offset2 + CustomerCategoryPeer.numColumns; 1637 1638 1639 RegionPeer.addSelectColumns(criteria); 1640 int offset4 = offset3 + RegionPeer.numColumns; 1641 1642 LanguagePeer.addSelectColumns(criteria); 1643 int offset5 = offset4 + LanguagePeer.numColumns; 1644 1645 EducationCategoryPeer.addSelectColumns(criteria); 1646 int offset6 = offset5 + EducationCategoryPeer.numColumns; 1647 1648 HouseholdCategoryPeer.addSelectColumns(criteria); 1649 int offset7 = offset6 + HouseholdCategoryPeer.numColumns; 1650 1651 List rows = BasePeer.doSelect(criteria); 1652 List results = new ArrayList (); 1653 1654 for (int i = 0; i < rows.size(); i++) 1655 { 1656 Record row = (Record)rows.get(i); 1657 1658 Class omClass = CustomerPeer.getOMClass(); 1659 Customer obj1 = (Customer)CustomerPeer 1660 .row2Object(row, 1, omClass); 1661 1662 1663 1664 1665 omClass = CustomerCategoryPeer.getOMClass(); 1666 CustomerCategory obj2 = (CustomerCategory)CustomerCategoryPeer 1667 .row2Object( row, offset2, omClass); 1668 1669 boolean newObject = true; 1670 for (int j = 0; j < results.size(); j++) 1671 { 1672 Customer temp_obj1 = (Customer)results.get(j); 1673 CustomerCategory temp_obj2 = (CustomerCategory)temp_obj1.getCustomerCategory(); 1674 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1675 { 1676 newObject = false; 1677 temp_obj2.addCustomer(obj1); 1678 break; 1679 } 1680 } 1681 if (newObject) 1682 { 1683 obj2.initCustomers(); 1684 obj2.addCustomer(obj1); 1685 } 1686 1687 1688 1689 1690 1691 omClass = RegionPeer.getOMClass(); 1692 Region obj3 = (Region)RegionPeer 1693 .row2Object( row, offset3, omClass); 1694 1695 newObject = true; 1696 for (int j = 0; j < results.size(); j++) 1697 { 1698 Customer temp_obj1 = (Customer)results.get(j); 1699 Region temp_obj3 = (Region)temp_obj1.getRegion(); 1700 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1701 { 1702 newObject = false; 1703 temp_obj3.addCustomer(obj1); 1704 break; 1705 } 1706 } 1707 if (newObject) 1708 { 1709 obj3.initCustomers(); 1710 obj3.addCustomer(obj1); 1711 } 1712 1713 1714 1715 1716 omClass = LanguagePeer.getOMClass(); 1717 Language obj4 = (Language)LanguagePeer 1718 .row2Object( row, offset4, omClass); 1719 1720 newObject = true; 1721 for (int j = 0; j < results.size(); j++) 1722 { 1723 Customer temp_obj1 = (Customer)results.get(j); 1724 Language temp_obj4 = (Language)temp_obj1.getLanguage(); 1725 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1726 { 1727 newObject = false; 1728 temp_obj4.addCustomer(obj1); 1729 break; 1730 } 1731 } 1732 if (newObject) 1733 { 1734 obj4.initCustomers(); 1735 obj4.addCustomer(obj1); 1736 } 1737 1738 1739 1740 1741 omClass = EducationCategoryPeer.getOMClass(); 1742 EducationCategory obj5 = (EducationCategory)EducationCategoryPeer 1743 .row2Object( row, offset5, omClass); 1744 1745 newObject = true; 1746 for (int j = 0; j < results.size(); j++) 1747 { 1748 Customer temp_obj1 = (Customer)results.get(j); 1749 EducationCategory temp_obj5 = (EducationCategory)temp_obj1.getEducationCategory(); 1750 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1751 { 1752 newObject = false; 1753 temp_obj5.addCustomer(obj1); 1754 break; 1755 } 1756 } 1757 if (newObject) 1758 { 1759 obj5.initCustomers(); 1760 obj5.addCustomer(obj1); 1761 } 1762 1763 1764 1765 1766 omClass = HouseholdCategoryPeer.getOMClass(); 1767 HouseholdCategory obj6 = (HouseholdCategory)HouseholdCategoryPeer 1768 .row2Object( row, offset6, omClass); 1769 1770 newObject = true; 1771 for (int j = 0; j < results.size(); j++) 1772 { 1773 Customer temp_obj1 = (Customer)results.get(j); 1774 HouseholdCategory temp_obj6 = (HouseholdCategory)temp_obj1.getHouseholdCategory(); 1775 if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) 1776 { 1777 newObject = false; 1778 temp_obj6.addCustomer(obj1); 1779 break; 1780 } 1781 } 1782 if (newObject) 1783 { 1784 obj6.initCustomers(); 1785 obj6.addCustomer(obj1); 1786 } 1787 results.add(obj1); 1788 } 1789 return results; 1790 } 1791 1792 1793 1794 1795 1796 1807 protected static List doSelectJoinAllExceptRegion(Criteria criteria) 1808 throws TorqueException 1809 { 1810 setDbName(criteria); 1811 1812 addSelectColumns(criteria); 1813 int offset2 = numColumns + 1; 1814 1815 CustomerCategoryPeer.addSelectColumns(criteria); 1816 int offset3 = offset2 + CustomerCategoryPeer.numColumns; 1817 1818 CountryPeer.addSelectColumns(criteria); 1819 int offset4 = offset3 + CountryPeer.numColumns; 1820 1821 1822 LanguagePeer.addSelectColumns(criteria); 1823 int offset5 = offset4 + LanguagePeer.numColumns; 1824 1825 EducationCategoryPeer.addSelectColumns(criteria); 1826 int offset6 = offset5 + EducationCategoryPeer.numColumns; 1827 1828 HouseholdCategoryPeer.addSelectColumns(criteria); 1829 int offset7 = offset6 + HouseholdCategoryPeer.numColumns; 1830 1831 List rows = BasePeer.doSelect(criteria); 1832 List results = new ArrayList (); 1833 1834 for (int i = 0; i < rows.size(); i++) 1835 { 1836 Record row = (Record)rows.get(i); 1837 1838 Class omClass = CustomerPeer.getOMClass(); 1839 Customer obj1 = (Customer)CustomerPeer 1840 .row2Object(row, 1, omClass); 1841 1842 1843 1844 1845 omClass = CustomerCategoryPeer.getOMClass(); 1846 CustomerCategory obj2 = (CustomerCategory)CustomerCategoryPeer 1847 .row2Object( row, offset2, omClass); 1848 1849 boolean newObject = true; 1850 for (int j = 0; j < results.size(); j++) 1851 { 1852 Customer temp_obj1 = (Customer)results.get(j); 1853 CustomerCategory temp_obj2 = (CustomerCategory)temp_obj1.getCustomerCategory(); 1854 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1855 { 1856 newObject = false; 1857 temp_obj2.addCustomer(obj1); 1858 break; 1859 } 1860 } 1861 if (newObject) 1862 { 1863 obj2.initCustomers(); 1864 obj2.addCustomer(obj1); 1865 } 1866 1867 1868 1869 1870 omClass = CountryPeer.getOMClass(); 1871 Country obj3 = (Country)CountryPeer 1872 .row2Object( row, offset3, omClass); 1873 1874 newObject = true; 1875 for (int j = 0; j < results.size(); j++) 1876 { 1877 Customer temp_obj1 = (Customer)results.get(j); 1878 Country temp_obj3 = (Country)temp_obj1.getCountry(); 1879 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1880 { 1881 newObject = false; 1882 temp_obj3.addCustomer(obj1); 1883 break; 1884 } 1885 } 1886 if (newObject) 1887 { 1888 obj3.initCustomers(); 1889 obj3.addCustomer(obj1); 1890 } 1891 1892 1893 1894 1895 1896 omClass = LanguagePeer.getOMClass(); 1897 Language obj4 = (Language)LanguagePeer 1898 .row2Object( row, offset4, omClass); 1899 1900 newObject = true; 1901 for (int j = 0; j < results.size(); j++) 1902 { 1903 Customer temp_obj1 = (Customer)results.get(j); 1904 Language temp_obj4 = (Language)temp_obj1.getLanguage(); 1905 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1906 { 1907 newObject = false; 1908 temp_obj4.addCustomer(obj1); 1909 break; 1910 } 1911 } 1912 if (newObject) 1913 { 1914 obj4.initCustomers(); 1915 obj4.addCustomer(obj1); 1916 } 1917 1918 1919 1920 1921 omClass = EducationCategoryPeer.getOMClass(); 1922 EducationCategory obj5 = (EducationCategory)EducationCategoryPeer 1923 .row2Object( row, offset5, omClass); 1924 1925 newObject = true; 1926 for (int j = 0; j < results.size(); j++) 1927 { 1928 Customer temp_obj1 = (Customer)results.get(j); 1929 EducationCategory temp_obj5 = (EducationCategory)temp_obj1.getEducationCategory(); 1930 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1931 { 1932 newObject = false; 1933 temp_obj5.addCustomer(obj1); 1934 break; 1935 } 1936 } 1937 if (newObject) 1938 { 1939 obj5.initCustomers(); 1940 obj5.addCustomer(obj1); 1941 } 1942 1943 1944 1945 1946 omClass = HouseholdCategoryPeer.getOMClass(); 1947 HouseholdCategory obj6 = (HouseholdCategory)HouseholdCategoryPeer 1948 .row2Object( row, offset6, omClass); 1949 1950 newObject = true; 1951 for (int j = 0; j < results.size(); j++) 1952 { 1953 Customer temp_obj1 = (Customer)results.get(j); 1954 HouseholdCategory temp_obj6 = (HouseholdCategory)temp_obj1.getHouseholdCategory(); 1955 if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) 1956 { 1957 newObject = false; 1958 temp_obj6.addCustomer(obj1); 1959 break; 1960 } 1961 } 1962 if (newObject) 1963 { 1964 obj6.initCustomers(); 1965 obj6.addCustomer(obj1); 1966 } 1967 results.add(obj1); 1968 } 1969 return results; 1970 } 1971 1972 1973 1974 1975 1976 1987 protected static List doSelectJoinAllExceptLanguage(Criteria criteria) 1988 throws TorqueException 1989 { 1990 setDbName(criteria); 1991 1992 addSelectColumns(criteria); 1993 int offset2 = numColumns + 1; 1994 1995 CustomerCategoryPeer.addSelectColumns(criteria); 1996 int offset3 = offset2 + CustomerCategoryPeer.numColumns; 1997 1998 CountryPeer.addSelectColumns(criteria); 1999 int offset4 = offset3 + CountryPeer.numColumns; 2000 2001 RegionPeer.addSelectColumns(criteria); 2002 int offset5 = offset4 + RegionPeer.numColumns; 2003 2004 2005 EducationCategoryPeer.addSelectColumns(criteria); 2006 int offset6 = offset5 + EducationCategoryPeer.numColumns; 2007 2008 HouseholdCategoryPeer.addSelectColumns(criteria); 2009 int offset7 = offset6 + HouseholdCategoryPeer.numColumns; 2010 2011 List rows = BasePeer.doSelect(criteria); 2012 List results = new ArrayList (); 2013 2014 for (int i = 0; i < rows.size(); i++) 2015 { 2016 Record row = (Record)rows.get(i); 2017 2018 Class omClass = CustomerPeer.getOMClass(); 2019 Customer obj1 = (Customer)CustomerPeer 2020 .row2Object(row, 1, omClass); 2021 2022 2023 2024 2025 omClass = CustomerCategoryPeer.getOMClass(); 2026 CustomerCategory obj2 = (CustomerCategory)CustomerCategoryPeer 2027 .row2Object( row, offset2, omClass); 2028 2029 boolean newObject = true; 2030 for (int j = 0; j < results.size(); j++) 2031 { 2032 Customer temp_obj1 = (Customer)results.get(j); 2033 CustomerCategory temp_obj2 = (CustomerCategory)temp_obj1.getCustomerCategory(); 2034 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 2035 { 2036 newObject = false; 2037 temp_obj2.addCustomer(obj1); 2038 break; 2039 } 2040 } 2041 if (newObject) 2042 { 2043 obj2.initCustomers(); 2044 obj2.addCustomer(obj1); 2045 } 2046 2047 2048 2049 2050 omClass = CountryPeer.getOMClass(); 2051 Country obj3 = (Country)CountryPeer 2052 .row2Object( row, offset3, omClass); 2053 2054 newObject = true; 2055 for (int j = 0; j < results.size(); j++) 2056 { 2057 Customer temp_obj1 = (Customer)results.get(j); 2058 Country temp_obj3 = (Country)temp_obj1.getCountry(); 2059 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 2060 { 2061 newObject = false; 2062 temp_obj3.addCustomer(obj1); 2063 break; 2064 } 2065 } 2066 if (newObject) 2067 { 2068 obj3.initCustomers(); 2069 obj3.addCustomer(obj1); 2070 } 2071 2072 2073 2074 2075 omClass = RegionPeer.getOMClass(); 2076 Region obj4 = (Region)RegionPeer 2077 .row2Object( row, offset4, omClass); 2078 2079 newObject = true; 2080 for (int j = 0; j < results.size(); j++) 2081 { 2082 Customer temp_obj1 = (Customer)results.get(j); 2083 Region temp_obj4 = (Region)temp_obj1.getRegion(); 2084 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 2085 { 2086 newObject = false; 2087 temp_obj4.addCustomer(obj1); 2088 break; 2089 } 2090 } 2091 if (newObject) 2092 { 2093 obj4.initCustomers(); 2094 obj4.addCustomer(obj1); 2095 } 2096 2097 2098 2099 2100 2101 omClass = EducationCategoryPeer.getOMClass(); 2102 EducationCategory obj5 = (EducationCategory)EducationCategoryPeer 2103 .row2Object( row, offset5, omClass); 2104 2105 newObject = true; 2106 for (int j = 0; j < results.size(); j++) 2107 { 2108 Customer temp_obj1 = (Customer)results.get(j); 2109 EducationCategory temp_obj5 = (EducationCategory)temp_obj1.getEducationCategory(); 2110 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 2111 { 2112 newObject = false; 2113 temp_obj5.addCustomer(obj1); 2114 break; 2115 } 2116 } 2117 if (newObject) 2118 { 2119 obj5.initCustomers(); 2120 obj5.addCustomer(obj1); 2121 } 2122 2123 2124 2125 2126 omClass = HouseholdCategoryPeer.getOMClass(); 2127 HouseholdCategory obj6 = (HouseholdCategory)HouseholdCategoryPeer 2128 .row2Object( row, offset6, omClass); 2129 2130 newObject = true; 2131 for (int j = 0; j < results.size(); j++) 2132 { 2133 Customer temp_obj1 = (Customer)results.get(j); 2134 HouseholdCategory temp_obj6 = (HouseholdCategory)temp_obj1.getHouseholdCategory(); 2135 if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) 2136 { 2137 newObject = false; 2138 temp_obj6.addCustomer(obj1); 2139 break; 2140 } 2141 } 2142 if (newObject) 2143 { 2144 obj6.initCustomers(); 2145 obj6.addCustomer(obj1); 2146 } 2147 results.add(obj1); 2148 } 2149 return results; 2150 } 2151 2152 2153 2154 2155 2156 2167 protected static List doSelectJoinAllExceptEducationCategory(Criteria criteria) 2168 throws TorqueException 2169 { 2170 setDbName(criteria); 2171 2172 addSelectColumns(criteria); 2173 int offset2 = numColumns + 1; 2174 2175 CustomerCategoryPeer.addSelectColumns(criteria); 2176 int offset3 = offset2 + CustomerCategoryPeer.numColumns; 2177 2178 CountryPeer.addSelectColumns(criteria); 2179 int offset4 = offset3 + CountryPeer.numColumns; 2180 2181 RegionPeer.addSelectColumns(criteria); 2182 int offset5 = offset4 + RegionPeer.numColumns; 2183 2184 LanguagePeer.addSelectColumns(criteria); 2185 int offset6 = offset5 + LanguagePeer.numColumns; 2186 2187 2188 HouseholdCategoryPeer.addSelectColumns(criteria); 2189 int offset7 = offset6 + HouseholdCategoryPeer.numColumns; 2190 2191 List rows = BasePeer.doSelect(criteria); 2192 List results = new ArrayList (); 2193 2194 for (int i = 0; i < rows.size(); i++) 2195 { 2196 Record row = (Record)rows.get(i); 2197 2198 Class omClass = CustomerPeer.getOMClass(); 2199 Customer obj1 = (Customer)CustomerPeer 2200 .row2Object(row, 1, omClass); 2201 2202 2203 2204 2205 omClass = CustomerCategoryPeer.getOMClass(); 2206 CustomerCategory obj2 = (CustomerCategory)CustomerCategoryPeer 2207 .row2Object( row, offset2, omClass); 2208 2209 boolean newObject = true; 2210 for (int j = 0; j < results.size(); j++) 2211 { 2212 Customer temp_obj1 = (Customer)results.get(j); 2213 CustomerCategory temp_obj2 = (CustomerCategory)temp_obj1.getCustomerCategory(); 2214 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 2215 { 2216 newObject = false; 2217 temp_obj2.addCustomer(obj1); 2218 break; 2219 } 2220 } 2221 if (newObject) 2222 { 2223 obj2.initCustomers(); 2224 obj2.addCustomer(obj1); 2225 } 2226 2227 2228 2229 2230 omClass = CountryPeer.getOMClass(); 2231 Country obj3 = (Country)CountryPeer 2232 .row2Object( row, offset3, omClass); 2233 2234 newObject = true; 2235 for (int j = 0; j < results.size(); j++) 2236 { 2237 Customer temp_obj1 = (Customer)results.get(j); 2238 Country temp_obj3 = (Country)temp_obj1.getCountry(); 2239 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 2240 { 2241 newObject = false; 2242 temp_obj3.addCustomer(obj1); 2243 break; 2244 } 2245 } 2246 if (newObject) 2247 { 2248 obj3.initCustomers(); 2249 obj3.addCustomer(obj1); 2250 } 2251 2252 2253 2254 2255 omClass = RegionPeer.getOMClass(); 2256 Region obj4 = (Region)RegionPeer 2257 .row2Object( row, offset4, omClass); 2258 2259 newObject = true; 2260 for (int j = 0; j < results.size(); j++) 2261 { 2262 Customer temp_obj1 = (Customer)results.get(j); 2263 Region temp_obj4 = (Region)temp_obj1.getRegion(); 2264 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 2265 { 2266 newObject = false; 2267 temp_obj4.addCustomer(obj1); 2268 break; 2269 } 2270 } 2271 if (newObject) 2272 { 2273 obj4.initCustomers(); 2274 obj4.addCustomer(obj1); 2275 } 2276 2277 2278 2279 2280 omClass = LanguagePeer.getOMClass(); 2281 Language obj5 = (Language)LanguagePeer 2282 .row2Object( row, offset5, omClass); 2283 2284 newObject = true; 2285 for (int j = 0; j < results.size(); j++) 2286 { 2287 Customer temp_obj1 = (Customer)results.get(j); 2288 Language temp_obj5 = (Language)temp_obj1.getLanguage(); 2289 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 2290 { 2291 newObject = false; 2292 temp_obj5.addCustomer(obj1); 2293 break; 2294 } 2295 } 2296 if (newObject) 2297 { 2298 obj5.initCustomers(); 2299 obj5.addCustomer(obj1); 2300 } 2301 2302 2303 2304 2305 2306 omClass = HouseholdCategoryPeer.getOMClass(); 2307 HouseholdCategory obj6 = (HouseholdCategory)HouseholdCategoryPeer 2308 .row2Object( row, offset6, omClass); 2309 2310 newObject = true; 2311 for (int j = 0; j < results.size(); j++) 2312 { 2313 Customer temp_obj1 = (Customer)results.get(j); 2314 HouseholdCategory temp_obj6 = (HouseholdCategory)temp_obj1.getHouseholdCategory(); 2315 if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) 2316 { 2317 newObject = false; 2318 temp_obj6.addCustomer(obj1); 2319 break; 2320 } 2321 } 2322 if (newObject) 2323 { 2324 obj6.initCustomers(); 2325 obj6.addCustomer(obj1); 2326 } 2327 results.add(obj1); 2328 } 2329 return results; 2330 } 2331 2332 2333 2334 2335 2336 2347 protected static List doSelectJoinAllExceptHouseholdCategory(Criteria criteria) 2348 throws TorqueException 2349 { 2350 setDbName(criteria); 2351 2352 addSelectColumns(criteria); 2353 int offset2 = numColumns + 1; 2354 2355 CustomerCategoryPeer.addSelectColumns(criteria); 2356 int offset3 = offset2 + CustomerCategoryPeer.numColumns; 2357 2358 CountryPeer.addSelectColumns(criteria); 2359 int offset4 = offset3 + CountryPeer.numColumns; 2360 2361 RegionPeer.addSelectColumns(criteria); 2362 int offset5 = offset4 + RegionPeer.numColumns; 2363 2364 LanguagePeer.addSelectColumns(criteria); 2365 int offset6 = offset5 + LanguagePeer.numColumns; 2366 2367 EducationCategoryPeer.addSelectColumns(criteria); 2368 int offset7 = offset6 + EducationCategoryPeer.numColumns; 2369 2370 2371 List rows = BasePeer.doSelect(criteria); 2372 List results = new ArrayList (); 2373 2374 for (int i = 0; i < rows.size(); i++) 2375 { 2376 Record row = (Record)rows.get(i); 2377 2378 Class omClass = CustomerPeer.getOMClass(); 2379 Customer obj1 = (Customer)CustomerPeer 2380 .row2Object(row, 1, omClass); 2381 2382 2383 2384 2385 omClass = CustomerCategoryPeer.getOMClass(); 2386 CustomerCategory obj2 = (CustomerCategory)CustomerCategoryPeer 2387 .row2Object( row, offset2, omClass); 2388 2389 boolean newObject = true; 2390 for (int j = 0; j < results.size(); j++) 2391 { 2392 Customer temp_obj1 = (Customer)results.get(j); 2393 CustomerCategory temp_obj2 = (CustomerCategory)temp_obj1.getCustomerCategory(); 2394 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 2395 { 2396 newObject = false; 2397 temp_obj2.addCustomer(obj1); 2398 break; 2399 } 2400 } 2401 if (newObject) 2402 { 2403 obj2.initCustomers(); 2404 obj2.addCustomer(obj1); 2405 } 2406 2407 2408 2409 2410 omClass = CountryPeer.getOMClass(); 2411 Country obj3 = (Country)CountryPeer 2412 .row2Object( row, offset3, omClass); 2413 2414 newObject = true; 2415 for (int j = 0; j < results.size(); j++) 2416 { 2417 Customer temp_obj1 = (Customer)results.get(j); 2418 Country temp_obj3 = (Country)temp_obj1.getCountry(); 2419 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 2420 { 2421 newObject = false; 2422 temp_obj3.addCustomer(obj1); 2423 break; 2424 } 2425 } 2426 if (newObject) 2427 { 2428 obj3.initCustomers(); 2429 obj3.addCustomer(obj1); 2430 } 2431 2432 2433 2434 2435 omClass = RegionPeer.getOMClass(); 2436 Region obj4 = (Region)RegionPeer 2437 .row2Object( row, offset4, omClass); 2438 2439 newObject = true; 2440 for (int j = 0; j < results.size(); j++) 2441 { 2442 Customer temp_obj1 = (Customer)results.get(j); 2443 Region temp_obj4 = (Region)temp_obj1.getRegion(); 2444 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 2445 { 2446 newObject = false; 2447 temp_obj4.addCustomer(obj1); 2448 break; 2449 } 2450 } 2451 if (newObject) 2452 { 2453 obj4.initCustomers(); 2454 obj4.addCustomer(obj1); 2455 } 2456 2457 2458 2459 2460 omClass = LanguagePeer.getOMClass(); 2461 Language obj5 = (Language)LanguagePeer 2462 .row2Object( row, offset5, omClass); 2463 2464 newObject = true; 2465 for (int j = 0; j < results.size(); j++) 2466 { 2467 Customer temp_obj1 = (Customer)results.get(j); 2468 Language temp_obj5 = (Language)temp_obj1.getLanguage(); 2469 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 2470 { 2471 newObject = false; 2472 temp_obj5.addCustomer(obj1); 2473 break; 2474 } 2475 } 2476 if (newObject) 2477 { 2478 obj5.initCustomers(); 2479 obj5.addCustomer(obj1); 2480 } 2481 2482 2483 2484 2485 omClass = EducationCategoryPeer.getOMClass(); 2486 EducationCategory obj6 = (EducationCategory)EducationCategoryPeer 2487 .row2Object( row, offset6, omClass); 2488 2489 newObject = true; 2490 for (int j = 0; j < results.size(); j++) 2491 { 2492 Customer temp_obj1 = (Customer)results.get(j); 2493 EducationCategory temp_obj6 = (EducationCategory)temp_obj1.getEducationCategory(); 2494 if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) 2495 { 2496 newObject = false; 2497 temp_obj6.addCustomer(obj1); 2498 break; 2499 } 2500 } 2501 if (newObject) 2502 { 2503 obj6.initCustomers(); 2504 obj6.addCustomer(obj1); 2505 } 2506 2507 results.add(obj1); 2508 } 2509 return results; 2510 } 2511 2512 2513 2520 protected static TableMap getTableMap() 2521 throws TorqueException 2522 { 2523 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 2524 } 2525 2526 private static void setDbName(Criteria crit) 2527 { 2528 if (crit.getDbName() == Torque.getDefaultDB()) 2532 { 2533 crit.setDbName(DATABASE_NAME); 2534 } 2535 } 2536} 2537
| Popular Tags
|