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 45 public abstract class BaseShipmentPeer 46 extends BasePeer 47 { 48 49 50 public static final String DATABASE_NAME = "cream"; 51 52 53 public static final String TABLE_NAME = "SHIPMENT"; 54 55 60 public static MapBuilder getMapBuilder() 61 throws TorqueException 62 { 63 return getMapBuilder(ShipmentMapBuilder.CLASS_NAME); 64 } 65 66 67 public static final String SHIPMENT_ID; 68 69 public static final String SHIPMENT_CODE; 70 71 public static final String STATUS; 72 73 public static final String PRIORITY; 74 75 public static final String ISSUED_DATE; 76 77 public static final String CLOSED_DATE; 78 79 public static final String CUSTOMER_ID; 80 81 public static final String RECIPIENT_ID; 82 83 public static final String PROJECT_ID; 84 85 public static final String SORDER_ID; 86 87 public static final String INVOICE_CODE; 88 89 public static final String CARRIER_ID; 90 91 public static final String SUBJECT; 92 93 public static final String NOTES; 94 95 public static final String CREATED; 96 97 public static final String MODIFIED; 98 99 public static final String CREATED_BY; 100 101 public static final String MODIFIED_BY; 102 103 static 104 { 105 SHIPMENT_ID = "SHIPMENT.SHIPMENT_ID"; 106 SHIPMENT_CODE = "SHIPMENT.SHIPMENT_CODE"; 107 STATUS = "SHIPMENT.STATUS"; 108 PRIORITY = "SHIPMENT.PRIORITY"; 109 ISSUED_DATE = "SHIPMENT.ISSUED_DATE"; 110 CLOSED_DATE = "SHIPMENT.CLOSED_DATE"; 111 CUSTOMER_ID = "SHIPMENT.CUSTOMER_ID"; 112 RECIPIENT_ID = "SHIPMENT.RECIPIENT_ID"; 113 PROJECT_ID = "SHIPMENT.PROJECT_ID"; 114 SORDER_ID = "SHIPMENT.SORDER_ID"; 115 INVOICE_CODE = "SHIPMENT.INVOICE_CODE"; 116 CARRIER_ID = "SHIPMENT.CARRIER_ID"; 117 SUBJECT = "SHIPMENT.SUBJECT"; 118 NOTES = "SHIPMENT.NOTES"; 119 CREATED = "SHIPMENT.CREATED"; 120 MODIFIED = "SHIPMENT.MODIFIED"; 121 CREATED_BY = "SHIPMENT.CREATED_BY"; 122 MODIFIED_BY = "SHIPMENT.MODIFIED_BY"; 123 if (Torque.isInit()) 124 { 125 try 126 { 127 getMapBuilder(ShipmentMapBuilder.CLASS_NAME); 128 } 129 catch (Exception e) 130 { 131 log.error("Could not initialize Peer", e); 132 } 133 } 134 else 135 { 136 Torque.registerMapBuilder(ShipmentMapBuilder.CLASS_NAME); 137 } 138 } 139 140 141 public static final int numColumns = 18; 142 143 144 protected static final String CLASSNAME_DEFAULT = 145 "org.campware.cream.om.Shipment"; 146 147 148 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 149 150 156 private static Class initClass(String className) 157 { 158 Class c = null; 159 try 160 { 161 c = Class.forName(className); 162 } 163 catch (Throwable t) 164 { 165 log.error("A FATAL ERROR has occurred which should not " 166 + "have happened under any circumstance. Please notify " 167 + "the Torque developers <torque-dev@db.apache.org> " 168 + "and give as many details as possible (including the error " 169 + "stack trace).", t); 170 171 if (t instanceof Error ) 173 { 174 throw (Error ) t.fillInStackTrace(); 175 } 176 } 177 return c; 178 } 179 180 190 public static List resultSet2Objects(java.sql.ResultSet results) 191 throws TorqueException 192 { 193 try 194 { 195 QueryDataSet qds = null; 196 List rows = null; 197 try 198 { 199 qds = new QueryDataSet(results); 200 rows = getSelectResults(qds); 201 } 202 finally 203 { 204 if (qds != null) 205 { 206 qds.close(); 207 } 208 } 209 210 return populateObjects(rows); 211 } 212 catch (SQLException e) 213 { 214 throw new TorqueException(e); 215 } 216 catch (DataSetException e) 217 { 218 throw new TorqueException(e); 219 } 220 } 221 222 223 224 231 public static ObjectKey doInsert(Criteria criteria) 232 throws TorqueException 233 { 234 return BaseShipmentPeer 235 .doInsert(criteria, (Connection ) null); 236 } 237 238 248 public static ObjectKey doInsert(Criteria criteria, Connection con) 249 throws TorqueException 250 { 251 252 setDbName(criteria); 253 254 if (con == null) 255 { 256 return BasePeer.doInsert(criteria); 257 } 258 else 259 { 260 return BasePeer.doInsert(criteria, con); 261 } 262 } 263 264 271 public static void addSelectColumns(Criteria criteria) 272 throws TorqueException 273 { 274 criteria.addSelectColumn(SHIPMENT_ID); 275 criteria.addSelectColumn(SHIPMENT_CODE); 276 criteria.addSelectColumn(STATUS); 277 criteria.addSelectColumn(PRIORITY); 278 criteria.addSelectColumn(ISSUED_DATE); 279 criteria.addSelectColumn(CLOSED_DATE); 280 criteria.addSelectColumn(CUSTOMER_ID); 281 criteria.addSelectColumn(RECIPIENT_ID); 282 criteria.addSelectColumn(PROJECT_ID); 283 criteria.addSelectColumn(SORDER_ID); 284 criteria.addSelectColumn(INVOICE_CODE); 285 criteria.addSelectColumn(CARRIER_ID); 286 criteria.addSelectColumn(SUBJECT); 287 criteria.addSelectColumn(NOTES); 288 criteria.addSelectColumn(CREATED); 289 criteria.addSelectColumn(MODIFIED); 290 criteria.addSelectColumn(CREATED_BY); 291 criteria.addSelectColumn(MODIFIED_BY); 292 } 293 294 303 public static Shipment row2Object(Record row, 304 int offset, 305 Class cls) 306 throws TorqueException 307 { 308 try 309 { 310 Shipment obj = (Shipment) cls.newInstance(); 311 ShipmentPeer.populateObject(row, offset, obj); 312 obj.setModified(false); 313 obj.setNew(false); 314 315 return obj; 316 } 317 catch (InstantiationException e) 318 { 319 throw new TorqueException(e); 320 } 321 catch (IllegalAccessException e) 322 { 323 throw new TorqueException(e); 324 } 325 } 326 327 336 public static void populateObject(Record row, 337 int offset, 338 Shipment obj) 339 throws TorqueException 340 { 341 try 342 { 343 obj.setShipmentId(row.getValue(offset + 0).asInt()); 344 obj.setShipmentCode(row.getValue(offset + 1).asString()); 345 obj.setStatus(row.getValue(offset + 2).asInt()); 346 obj.setPriority(row.getValue(offset + 3).asInt()); 347 obj.setIssuedDate(row.getValue(offset + 4).asUtilDate()); 348 obj.setClosedDate(row.getValue(offset + 5).asUtilDate()); 349 obj.setCustomerId(row.getValue(offset + 6).asInt()); 350 obj.setRecipientId(row.getValue(offset + 7).asInt()); 351 obj.setProjectId(row.getValue(offset + 8).asInt()); 352 obj.setSorderId(row.getValue(offset + 9).asInt()); 353 obj.setInvoiceCode(row.getValue(offset + 10).asString()); 354 obj.setCarrierId(row.getValue(offset + 11).asInt()); 355 obj.setSubject(row.getValue(offset + 12).asString()); 356 obj.setNotes(row.getValue(offset + 13).asString()); 357 obj.setCreated(row.getValue(offset + 14).asUtilDate()); 358 obj.setModified(row.getValue(offset + 15).asUtilDate()); 359 obj.setCreatedBy(row.getValue(offset + 16).asString()); 360 obj.setModifiedBy(row.getValue(offset + 17).asString()); 361 } 362 catch (DataSetException e) 363 { 364 throw new TorqueException(e); 365 } 366 } 367 368 376 public static List doSelect(Criteria criteria) throws TorqueException 377 { 378 return populateObjects(doSelectVillageRecords(criteria)); 379 } 380 381 390 public static List doSelect(Criteria criteria, Connection con) 391 throws TorqueException 392 { 393 return populateObjects(doSelectVillageRecords(criteria, con)); 394 } 395 396 406 public static List doSelectVillageRecords(Criteria criteria) 407 throws TorqueException 408 { 409 return BaseShipmentPeer 410 .doSelectVillageRecords(criteria, (Connection ) null); 411 } 412 413 422 public static List doSelectVillageRecords(Criteria criteria, Connection con) 423 throws TorqueException 424 { 425 if (criteria.getSelectColumns().size() == 0) 426 { 427 addSelectColumns(criteria); 428 } 429 430 431 setDbName(criteria); 432 433 if (con == null) 436 { 437 return BasePeer.doSelect(criteria); 438 } 439 else 440 { 441 return BasePeer.doSelect(criteria, con); 442 } 443 } 444 445 452 public static List populateObjects(List records) 453 throws TorqueException 454 { 455 List results = new ArrayList (records.size()); 456 457 for (int i = 0; i < records.size(); i++) 459 { 460 Record row = (Record) records.get(i); 461 results.add(ShipmentPeer.row2Object(row, 1, 462 ShipmentPeer.getOMClass())); 463 } 464 return results; 465 } 466 467 468 476 public static Class getOMClass() 477 throws TorqueException 478 { 479 return CLASS_DEFAULT; 480 } 481 482 490 public static void doUpdate(Criteria criteria) throws TorqueException 491 { 492 BaseShipmentPeer 493 .doUpdate(criteria, (Connection ) null); 494 } 495 496 507 public static void doUpdate(Criteria criteria, Connection con) 508 throws TorqueException 509 { 510 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 511 selectCriteria.put(SHIPMENT_ID, criteria.remove(SHIPMENT_ID)); 512 513 setDbName(criteria); 514 515 if (con == null) 516 { 517 BasePeer.doUpdate(selectCriteria, criteria); 518 } 519 else 520 { 521 BasePeer.doUpdate(selectCriteria, criteria, con); 522 } 523 } 524 525 532 public static void doDelete(Criteria criteria) throws TorqueException 533 { 534 ShipmentPeer 535 .doDelete(criteria, (Connection ) null); 536 } 537 538 548 public static void doDelete(Criteria criteria, Connection con) 549 throws TorqueException 550 { 551 552 setDbName(criteria); 553 554 if (con == null) 555 { 556 BasePeer.doDelete(criteria); 557 } 558 else 559 { 560 BasePeer.doDelete(criteria, con); 561 } 562 } 563 564 570 public static List doSelect(Shipment obj) throws TorqueException 571 { 572 return doSelect(buildSelectCriteria(obj)); 573 } 574 575 581 public static void doInsert(Shipment obj) throws TorqueException 582 { 583 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 584 obj.setNew(false); 585 obj.setModified(false); 586 } 587 588 593 public static void doUpdate(Shipment obj) throws TorqueException 594 { 595 doUpdate(buildCriteria(obj)); 596 obj.setModified(false); 597 } 598 599 604 public static void doDelete(Shipment obj) throws TorqueException 605 { 606 doDelete(buildSelectCriteria(obj)); 607 } 608 609 619 public static void doInsert(Shipment obj, Connection con) 620 throws TorqueException 621 { 622 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 623 obj.setNew(false); 624 obj.setModified(false); 625 } 626 627 637 public static void doUpdate(Shipment obj, Connection con) 638 throws TorqueException 639 { 640 doUpdate(buildCriteria(obj), con); 641 obj.setModified(false); 642 } 643 644 654 public static void doDelete(Shipment obj, Connection con) 655 throws TorqueException 656 { 657 doDelete(buildSelectCriteria(obj), con); 658 } 659 660 667 public static void doDelete(ObjectKey pk) throws TorqueException 668 { 669 BaseShipmentPeer 670 .doDelete(pk, (Connection ) null); 671 } 672 673 683 public static void doDelete(ObjectKey pk, Connection con) 684 throws TorqueException 685 { 686 doDelete(buildCriteria(pk), con); 687 } 688 689 690 public static Criteria buildCriteria( ObjectKey pk ) 691 { 692 Criteria criteria = new Criteria(); 693 criteria.add(SHIPMENT_ID, pk); 694 return criteria; 695 } 696 697 698 public static Criteria buildCriteria( Shipment obj ) 699 { 700 Criteria criteria = new Criteria(DATABASE_NAME); 701 if (!obj.isNew()) 702 criteria.add(SHIPMENT_ID, obj.getShipmentId()); 703 criteria.add(SHIPMENT_CODE, obj.getShipmentCode()); 704 criteria.add(STATUS, obj.getStatus()); 705 criteria.add(PRIORITY, obj.getPriority()); 706 criteria.add(ISSUED_DATE, obj.getIssuedDate()); 707 criteria.add(CLOSED_DATE, obj.getClosedDate()); 708 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 709 criteria.add(RECIPIENT_ID, obj.getRecipientId()); 710 criteria.add(PROJECT_ID, obj.getProjectId()); 711 criteria.add(SORDER_ID, obj.getSorderId()); 712 criteria.add(INVOICE_CODE, obj.getInvoiceCode()); 713 criteria.add(CARRIER_ID, obj.getCarrierId()); 714 criteria.add(SUBJECT, obj.getSubject()); 715 criteria.add(NOTES, obj.getNotes()); 716 criteria.add(CREATED, obj.getCreated()); 717 criteria.add(MODIFIED, obj.getModified()); 718 criteria.add(CREATED_BY, obj.getCreatedBy()); 719 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 720 return criteria; 721 } 722 723 724 public static Criteria buildSelectCriteria( Shipment obj ) 725 { 726 Criteria criteria = new Criteria(DATABASE_NAME); 727 if (!obj.isNew()) 728 criteria.add(SHIPMENT_ID, obj.getShipmentId()); 729 criteria.add(SHIPMENT_CODE, obj.getShipmentCode()); 730 criteria.add(STATUS, obj.getStatus()); 731 criteria.add(PRIORITY, obj.getPriority()); 732 criteria.add(ISSUED_DATE, obj.getIssuedDate()); 733 criteria.add(CLOSED_DATE, obj.getClosedDate()); 734 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 735 criteria.add(RECIPIENT_ID, obj.getRecipientId()); 736 criteria.add(PROJECT_ID, obj.getProjectId()); 737 criteria.add(SORDER_ID, obj.getSorderId()); 738 criteria.add(INVOICE_CODE, obj.getInvoiceCode()); 739 criteria.add(CARRIER_ID, obj.getCarrierId()); 740 criteria.add(SUBJECT, obj.getSubject()); 741 criteria.add(NOTES, obj.getNotes()); 742 criteria.add(CREATED, obj.getCreated()); 743 criteria.add(MODIFIED, obj.getModified()); 744 criteria.add(CREATED_BY, obj.getCreatedBy()); 745 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 746 return criteria; 747 } 748 749 750 759 public static Shipment retrieveByPK(int pk) 760 throws TorqueException, NoRowsException, TooManyRowsException 761 { 762 return retrieveByPK(SimpleKey.keyFor(pk)); 763 } 764 765 775 public static Shipment retrieveByPK(int pk, Connection con) 776 throws TorqueException, NoRowsException, TooManyRowsException 777 { 778 return retrieveByPK(SimpleKey.keyFor(pk), con); 779 } 780 781 790 public static Shipment retrieveByPK(ObjectKey pk) 791 throws TorqueException, NoRowsException, TooManyRowsException 792 { 793 Connection db = null; 794 Shipment retVal = null; 795 try 796 { 797 db = Torque.getConnection(DATABASE_NAME); 798 retVal = retrieveByPK(pk, db); 799 } 800 finally 801 { 802 Torque.closeConnection(db); 803 } 804 return(retVal); 805 } 806 807 817 public static Shipment retrieveByPK(ObjectKey pk, Connection con) 818 throws TorqueException, NoRowsException, TooManyRowsException 819 { 820 Criteria criteria = buildCriteria(pk); 821 List v = doSelect(criteria, con); 822 if (v.size() == 0) 823 { 824 throw new NoRowsException("Failed to select a row."); 825 } 826 else if (v.size() > 1) 827 { 828 throw new TooManyRowsException("Failed to select only one row."); 829 } 830 else 831 { 832 return (Shipment)v.get(0); 833 } 834 } 835 836 843 public static List retrieveByPKs(List pks) 844 throws TorqueException 845 { 846 Connection db = null; 847 List retVal = null; 848 try 849 { 850 db = Torque.getConnection(DATABASE_NAME); 851 retVal = retrieveByPKs(pks, db); 852 } 853 finally 854 { 855 Torque.closeConnection(db); 856 } 857 return(retVal); 858 } 859 860 868 public static List retrieveByPKs( List pks, Connection dbcon ) 869 throws TorqueException 870 { 871 List objs = null; 872 if (pks == null || pks.size() == 0) 873 { 874 objs = new LinkedList (); 875 } 876 else 877 { 878 Criteria criteria = new Criteria(); 879 criteria.addIn( SHIPMENT_ID, pks ); 880 objs = doSelect(criteria, dbcon); 881 } 882 return objs; 883 } 884 885 886 887 888 889 890 891 892 893 894 905 protected static List doSelectJoinCustomerRelatedByCustomerId(Criteria criteria) 906 throws TorqueException 907 { 908 setDbName(criteria); 909 910 ShipmentPeer.addSelectColumns(criteria); 911 int offset = numColumns + 1; 912 CustomerPeer.addSelectColumns(criteria); 913 914 915 criteria.addJoin(ShipmentPeer.CUSTOMER_ID, 916 CustomerPeer.CUSTOMER_ID); 917 918 919 920 List rows = BasePeer.doSelect(criteria); 921 List results = new ArrayList (); 922 923 for (int i = 0; i < rows.size(); i++) 924 { 925 Record row = (Record) rows.get(i); 926 927 Class omClass = ShipmentPeer.getOMClass(); 928 Shipment obj1 = (Shipment) ShipmentPeer 929 .row2Object(row, 1, omClass); 930 omClass = CustomerPeer.getOMClass(); 931 Customer obj2 = (Customer)CustomerPeer 932 .row2Object(row, offset, omClass); 933 934 boolean newObject = true; 935 for (int j = 0; j < results.size(); j++) 936 { 937 Shipment temp_obj1 = (Shipment)results.get(j); 938 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 939 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 940 { 941 newObject = false; 942 temp_obj2.addShipmentRelatedByCustomerId(obj1); 943 break; 944 } 945 } 946 if (newObject) 947 { 948 obj2.initShipmentsRelatedByCustomerId(); 949 obj2.addShipmentRelatedByCustomerId(obj1); 950 } 951 results.add(obj1); 952 } 953 return results; 954 } 955 956 957 958 959 970 protected static List doSelectJoinCustomerRelatedByRecipientId(Criteria criteria) 971 throws TorqueException 972 { 973 setDbName(criteria); 974 975 ShipmentPeer.addSelectColumns(criteria); 976 int offset = numColumns + 1; 977 CustomerPeer.addSelectColumns(criteria); 978 979 980 criteria.addJoin(ShipmentPeer.RECIPIENT_ID, 981 CustomerPeer.CUSTOMER_ID); 982 983 984 985 List rows = BasePeer.doSelect(criteria); 986 List results = new ArrayList (); 987 988 for (int i = 0; i < rows.size(); i++) 989 { 990 Record row = (Record) rows.get(i); 991 992 Class omClass = ShipmentPeer.getOMClass(); 993 Shipment obj1 = (Shipment) ShipmentPeer 994 .row2Object(row, 1, omClass); 995 omClass = CustomerPeer.getOMClass(); 996 Customer obj2 = (Customer)CustomerPeer 997 .row2Object(row, offset, omClass); 998 999 boolean newObject = true; 1000 for (int j = 0; j < results.size(); j++) 1001 { 1002 Shipment temp_obj1 = (Shipment)results.get(j); 1003 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 1004 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1005 { 1006 newObject = false; 1007 temp_obj2.addShipmentRelatedByRecipientId(obj1); 1008 break; 1009 } 1010 } 1011 if (newObject) 1012 { 1013 obj2.initShipmentsRelatedByRecipientId(); 1014 obj2.addShipmentRelatedByRecipientId(obj1); 1015 } 1016 results.add(obj1); 1017 } 1018 return results; 1019 } 1020 1021 1022 1023 1024 1035 protected static List doSelectJoinProject(Criteria criteria) 1036 throws TorqueException 1037 { 1038 setDbName(criteria); 1039 1040 ShipmentPeer.addSelectColumns(criteria); 1041 int offset = numColumns + 1; 1042 ProjectPeer.addSelectColumns(criteria); 1043 1044 1045 criteria.addJoin(ShipmentPeer.PROJECT_ID, 1046 ProjectPeer.PROJECT_ID); 1047 1048 1049 1050 List rows = BasePeer.doSelect(criteria); 1051 List results = new ArrayList (); 1052 1053 for (int i = 0; i < rows.size(); i++) 1054 { 1055 Record row = (Record) rows.get(i); 1056 1057 Class omClass = ShipmentPeer.getOMClass(); 1058 Shipment obj1 = (Shipment) ShipmentPeer 1059 .row2Object(row, 1, omClass); 1060 omClass = ProjectPeer.getOMClass(); 1061 Project obj2 = (Project)ProjectPeer 1062 .row2Object(row, offset, omClass); 1063 1064 boolean newObject = true; 1065 for (int j = 0; j < results.size(); j++) 1066 { 1067 Shipment temp_obj1 = (Shipment)results.get(j); 1068 Project temp_obj2 = (Project)temp_obj1.getProject(); 1069 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1070 { 1071 newObject = false; 1072 temp_obj2.addShipment(obj1); 1073 break; 1074 } 1075 } 1076 if (newObject) 1077 { 1078 obj2.initShipments(); 1079 obj2.addShipment(obj1); 1080 } 1081 results.add(obj1); 1082 } 1083 return results; 1084 } 1085 1086 1087 1088 1089 1100 protected static List doSelectJoinSorder(Criteria criteria) 1101 throws TorqueException 1102 { 1103 setDbName(criteria); 1104 1105 ShipmentPeer.addSelectColumns(criteria); 1106 int offset = numColumns + 1; 1107 SorderPeer.addSelectColumns(criteria); 1108 1109 1110 criteria.addJoin(ShipmentPeer.SORDER_ID, 1111 SorderPeer.SORDER_ID); 1112 1113 1114 1115 List rows = BasePeer.doSelect(criteria); 1116 List results = new ArrayList (); 1117 1118 for (int i = 0; i < rows.size(); i++) 1119 { 1120 Record row = (Record) rows.get(i); 1121 1122 Class omClass = ShipmentPeer.getOMClass(); 1123 Shipment obj1 = (Shipment) ShipmentPeer 1124 .row2Object(row, 1, omClass); 1125 omClass = SorderPeer.getOMClass(); 1126 Sorder obj2 = (Sorder)SorderPeer 1127 .row2Object(row, offset, omClass); 1128 1129 boolean newObject = true; 1130 for (int j = 0; j < results.size(); j++) 1131 { 1132 Shipment temp_obj1 = (Shipment)results.get(j); 1133 Sorder temp_obj2 = (Sorder)temp_obj1.getSorder(); 1134 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1135 { 1136 newObject = false; 1137 temp_obj2.addShipment(obj1); 1138 break; 1139 } 1140 } 1141 if (newObject) 1142 { 1143 obj2.initShipments(); 1144 obj2.addShipment(obj1); 1145 } 1146 results.add(obj1); 1147 } 1148 return results; 1149 } 1150 1151 1152 1153 1154 1165 protected static List doSelectJoinCarrier(Criteria criteria) 1166 throws TorqueException 1167 { 1168 setDbName(criteria); 1169 1170 ShipmentPeer.addSelectColumns(criteria); 1171 int offset = numColumns + 1; 1172 CarrierPeer.addSelectColumns(criteria); 1173 1174 1175 criteria.addJoin(ShipmentPeer.CARRIER_ID, 1176 CarrierPeer.CARRIER_ID); 1177 1178 1179 1180 List rows = BasePeer.doSelect(criteria); 1181 List results = new ArrayList (); 1182 1183 for (int i = 0; i < rows.size(); i++) 1184 { 1185 Record row = (Record) rows.get(i); 1186 1187 Class omClass = ShipmentPeer.getOMClass(); 1188 Shipment obj1 = (Shipment) ShipmentPeer 1189 .row2Object(row, 1, omClass); 1190 omClass = CarrierPeer.getOMClass(); 1191 Carrier obj2 = (Carrier)CarrierPeer 1192 .row2Object(row, offset, omClass); 1193 1194 boolean newObject = true; 1195 for (int j = 0; j < results.size(); j++) 1196 { 1197 Shipment temp_obj1 = (Shipment)results.get(j); 1198 Carrier temp_obj2 = (Carrier)temp_obj1.getCarrier(); 1199 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1200 { 1201 newObject = false; 1202 temp_obj2.addShipment(obj1); 1203 break; 1204 } 1205 } 1206 if (newObject) 1207 { 1208 obj2.initShipments(); 1209 obj2.addShipment(obj1); 1210 } 1211 results.add(obj1); 1212 } 1213 return results; 1214 } 1215 1216 1217 1218 1219 1220 1221 1222 1223 1234 protected static List doSelectJoinAllExceptCustomerRelatedByCustomerId(Criteria criteria) 1235 throws TorqueException 1236 { 1237 setDbName(criteria); 1238 1239 addSelectColumns(criteria); 1240 int offset2 = numColumns + 1; 1241 1242 1243 1244 ProjectPeer.addSelectColumns(criteria); 1245 int offset3 = offset2 + ProjectPeer.numColumns; 1246 1247 SorderPeer.addSelectColumns(criteria); 1248 int offset4 = offset3 + SorderPeer.numColumns; 1249 1250 CarrierPeer.addSelectColumns(criteria); 1251 int offset5 = offset4 + CarrierPeer.numColumns; 1252 1253 List rows = BasePeer.doSelect(criteria); 1254 List results = new ArrayList (); 1255 1256 for (int i = 0; i < rows.size(); i++) 1257 { 1258 Record row = (Record)rows.get(i); 1259 1260 Class omClass = ShipmentPeer.getOMClass(); 1261 Shipment obj1 = (Shipment)ShipmentPeer 1262 .row2Object(row, 1, omClass); 1263 1264 1265 1266 1267 1268 1269 omClass = ProjectPeer.getOMClass(); 1270 Project obj2 = (Project)ProjectPeer 1271 .row2Object( row, offset2, omClass); 1272 1273 boolean newObject = true; 1274 for (int j = 0; j < results.size(); j++) 1275 { 1276 Shipment temp_obj1 = (Shipment)results.get(j); 1277 Project temp_obj2 = (Project)temp_obj1.getProject(); 1278 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1279 { 1280 newObject = false; 1281 temp_obj2.addShipment(obj1); 1282 break; 1283 } 1284 } 1285 if (newObject) 1286 { 1287 obj2.initShipments(); 1288 obj2.addShipment(obj1); 1289 } 1290 1291 1292 1293 1294 omClass = SorderPeer.getOMClass(); 1295 Sorder obj3 = (Sorder)SorderPeer 1296 .row2Object( row, offset3, omClass); 1297 1298 newObject = true; 1299 for (int j = 0; j < results.size(); j++) 1300 { 1301 Shipment temp_obj1 = (Shipment)results.get(j); 1302 Sorder temp_obj3 = (Sorder)temp_obj1.getSorder(); 1303 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1304 { 1305 newObject = false; 1306 temp_obj3.addShipment(obj1); 1307 break; 1308 } 1309 } 1310 if (newObject) 1311 { 1312 obj3.initShipments(); 1313 obj3.addShipment(obj1); 1314 } 1315 1316 1317 1318 1319 omClass = CarrierPeer.getOMClass(); 1320 Carrier obj4 = (Carrier)CarrierPeer 1321 .row2Object( row, offset4, omClass); 1322 1323 newObject = true; 1324 for (int j = 0; j < results.size(); j++) 1325 { 1326 Shipment temp_obj1 = (Shipment)results.get(j); 1327 Carrier temp_obj4 = (Carrier)temp_obj1.getCarrier(); 1328 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1329 { 1330 newObject = false; 1331 temp_obj4.addShipment(obj1); 1332 break; 1333 } 1334 } 1335 if (newObject) 1336 { 1337 obj4.initShipments(); 1338 obj4.addShipment(obj1); 1339 } 1340 results.add(obj1); 1341 } 1342 return results; 1343 } 1344 1345 1346 1347 1348 1349 1360 protected static List doSelectJoinAllExceptCustomerRelatedByRecipientId(Criteria criteria) 1361 throws TorqueException 1362 { 1363 setDbName(criteria); 1364 1365 addSelectColumns(criteria); 1366 int offset2 = numColumns + 1; 1367 1368 1369 1370 ProjectPeer.addSelectColumns(criteria); 1371 int offset3 = offset2 + ProjectPeer.numColumns; 1372 1373 SorderPeer.addSelectColumns(criteria); 1374 int offset4 = offset3 + SorderPeer.numColumns; 1375 1376 CarrierPeer.addSelectColumns(criteria); 1377 int offset5 = offset4 + CarrierPeer.numColumns; 1378 1379 List rows = BasePeer.doSelect(criteria); 1380 List results = new ArrayList (); 1381 1382 for (int i = 0; i < rows.size(); i++) 1383 { 1384 Record row = (Record)rows.get(i); 1385 1386 Class omClass = ShipmentPeer.getOMClass(); 1387 Shipment obj1 = (Shipment)ShipmentPeer 1388 .row2Object(row, 1, omClass); 1389 1390 1391 1392 1393 1394 1395 omClass = ProjectPeer.getOMClass(); 1396 Project obj2 = (Project)ProjectPeer 1397 .row2Object( row, offset2, omClass); 1398 1399 boolean newObject = true; 1400 for (int j = 0; j < results.size(); j++) 1401 { 1402 Shipment temp_obj1 = (Shipment)results.get(j); 1403 Project temp_obj2 = (Project)temp_obj1.getProject(); 1404 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1405 { 1406 newObject = false; 1407 temp_obj2.addShipment(obj1); 1408 break; 1409 } 1410 } 1411 if (newObject) 1412 { 1413 obj2.initShipments(); 1414 obj2.addShipment(obj1); 1415 } 1416 1417 1418 1419 1420 omClass = SorderPeer.getOMClass(); 1421 Sorder obj3 = (Sorder)SorderPeer 1422 .row2Object( row, offset3, omClass); 1423 1424 newObject = true; 1425 for (int j = 0; j < results.size(); j++) 1426 { 1427 Shipment temp_obj1 = (Shipment)results.get(j); 1428 Sorder temp_obj3 = (Sorder)temp_obj1.getSorder(); 1429 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1430 { 1431 newObject = false; 1432 temp_obj3.addShipment(obj1); 1433 break; 1434 } 1435 } 1436 if (newObject) 1437 { 1438 obj3.initShipments(); 1439 obj3.addShipment(obj1); 1440 } 1441 1442 1443 1444 1445 omClass = CarrierPeer.getOMClass(); 1446 Carrier obj4 = (Carrier)CarrierPeer 1447 .row2Object( row, offset4, omClass); 1448 1449 newObject = true; 1450 for (int j = 0; j < results.size(); j++) 1451 { 1452 Shipment temp_obj1 = (Shipment)results.get(j); 1453 Carrier temp_obj4 = (Carrier)temp_obj1.getCarrier(); 1454 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1455 { 1456 newObject = false; 1457 temp_obj4.addShipment(obj1); 1458 break; 1459 } 1460 } 1461 if (newObject) 1462 { 1463 obj4.initShipments(); 1464 obj4.addShipment(obj1); 1465 } 1466 results.add(obj1); 1467 } 1468 return results; 1469 } 1470 1471 1472 1473 1474 1475 1486 protected static List doSelectJoinAllExceptProject(Criteria criteria) 1487 throws TorqueException 1488 { 1489 setDbName(criteria); 1490 1491 addSelectColumns(criteria); 1492 int offset2 = numColumns + 1; 1493 1494 CustomerPeer.addSelectColumns(criteria); 1495 int offset3 = offset2 + CustomerPeer.numColumns; 1496 1497 CustomerPeer.addSelectColumns(criteria); 1498 int offset4 = offset3 + CustomerPeer.numColumns; 1499 1500 1501 SorderPeer.addSelectColumns(criteria); 1502 int offset5 = offset4 + SorderPeer.numColumns; 1503 1504 CarrierPeer.addSelectColumns(criteria); 1505 int offset6 = offset5 + CarrierPeer.numColumns; 1506 1507 List rows = BasePeer.doSelect(criteria); 1508 List results = new ArrayList (); 1509 1510 for (int i = 0; i < rows.size(); i++) 1511 { 1512 Record row = (Record)rows.get(i); 1513 1514 Class omClass = ShipmentPeer.getOMClass(); 1515 Shipment obj1 = (Shipment)ShipmentPeer 1516 .row2Object(row, 1, omClass); 1517 1518 1519 1520 1521 omClass = CustomerPeer.getOMClass(); 1522 Customer obj2 = (Customer)CustomerPeer 1523 .row2Object( row, offset2, omClass); 1524 1525 boolean newObject = true; 1526 for (int j = 0; j < results.size(); j++) 1527 { 1528 Shipment temp_obj1 = (Shipment)results.get(j); 1529 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 1530 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1531 { 1532 newObject = false; 1533 temp_obj2.addShipmentRelatedByCustomerId(obj1); 1534 break; 1535 } 1536 } 1537 if (newObject) 1538 { 1539 obj2.initShipmentsRelatedByCustomerId(); 1540 obj2.addShipmentRelatedByCustomerId(obj1); 1541 } 1542 1543 1544 1545 1546 omClass = CustomerPeer.getOMClass(); 1547 Customer obj3 = (Customer)CustomerPeer 1548 .row2Object( row, offset3, omClass); 1549 1550 newObject = true; 1551 for (int j = 0; j < results.size(); j++) 1552 { 1553 Shipment temp_obj1 = (Shipment)results.get(j); 1554 Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 1555 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1556 { 1557 newObject = false; 1558 temp_obj3.addShipmentRelatedByRecipientId(obj1); 1559 break; 1560 } 1561 } 1562 if (newObject) 1563 { 1564 obj3.initShipmentsRelatedByRecipientId(); 1565 obj3.addShipmentRelatedByRecipientId(obj1); 1566 } 1567 1568 1569 1570 1571 1572 omClass = SorderPeer.getOMClass(); 1573 Sorder obj4 = (Sorder)SorderPeer 1574 .row2Object( row, offset4, omClass); 1575 1576 newObject = true; 1577 for (int j = 0; j < results.size(); j++) 1578 { 1579 Shipment temp_obj1 = (Shipment)results.get(j); 1580 Sorder temp_obj4 = (Sorder)temp_obj1.getSorder(); 1581 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1582 { 1583 newObject = false; 1584 temp_obj4.addShipment(obj1); 1585 break; 1586 } 1587 } 1588 if (newObject) 1589 { 1590 obj4.initShipments(); 1591 obj4.addShipment(obj1); 1592 } 1593 1594 1595 1596 1597 omClass = CarrierPeer.getOMClass(); 1598 Carrier obj5 = (Carrier)CarrierPeer 1599 .row2Object( row, offset5, omClass); 1600 1601 newObject = true; 1602 for (int j = 0; j < results.size(); j++) 1603 { 1604 Shipment temp_obj1 = (Shipment)results.get(j); 1605 Carrier temp_obj5 = (Carrier)temp_obj1.getCarrier(); 1606 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1607 { 1608 newObject = false; 1609 temp_obj5.addShipment(obj1); 1610 break; 1611 } 1612 } 1613 if (newObject) 1614 { 1615 obj5.initShipments(); 1616 obj5.addShipment(obj1); 1617 } 1618 results.add(obj1); 1619 } 1620 return results; 1621 } 1622 1623 1624 1625 1626 1627 1638 protected static List doSelectJoinAllExceptSorder(Criteria criteria) 1639 throws TorqueException 1640 { 1641 setDbName(criteria); 1642 1643 addSelectColumns(criteria); 1644 int offset2 = numColumns + 1; 1645 1646 CustomerPeer.addSelectColumns(criteria); 1647 int offset3 = offset2 + CustomerPeer.numColumns; 1648 1649 CustomerPeer.addSelectColumns(criteria); 1650 int offset4 = offset3 + CustomerPeer.numColumns; 1651 1652 ProjectPeer.addSelectColumns(criteria); 1653 int offset5 = offset4 + ProjectPeer.numColumns; 1654 1655 1656 CarrierPeer.addSelectColumns(criteria); 1657 int offset6 = offset5 + CarrierPeer.numColumns; 1658 1659 List rows = BasePeer.doSelect(criteria); 1660 List results = new ArrayList (); 1661 1662 for (int i = 0; i < rows.size(); i++) 1663 { 1664 Record row = (Record)rows.get(i); 1665 1666 Class omClass = ShipmentPeer.getOMClass(); 1667 Shipment obj1 = (Shipment)ShipmentPeer 1668 .row2Object(row, 1, omClass); 1669 1670 1671 1672 1673 omClass = CustomerPeer.getOMClass(); 1674 Customer obj2 = (Customer)CustomerPeer 1675 .row2Object( row, offset2, omClass); 1676 1677 boolean newObject = true; 1678 for (int j = 0; j < results.size(); j++) 1679 { 1680 Shipment temp_obj1 = (Shipment)results.get(j); 1681 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 1682 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1683 { 1684 newObject = false; 1685 temp_obj2.addShipmentRelatedByCustomerId(obj1); 1686 break; 1687 } 1688 } 1689 if (newObject) 1690 { 1691 obj2.initShipmentsRelatedByCustomerId(); 1692 obj2.addShipmentRelatedByCustomerId(obj1); 1693 } 1694 1695 1696 1697 1698 omClass = CustomerPeer.getOMClass(); 1699 Customer obj3 = (Customer)CustomerPeer 1700 .row2Object( row, offset3, omClass); 1701 1702 newObject = true; 1703 for (int j = 0; j < results.size(); j++) 1704 { 1705 Shipment temp_obj1 = (Shipment)results.get(j); 1706 Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 1707 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1708 { 1709 newObject = false; 1710 temp_obj3.addShipmentRelatedByRecipientId(obj1); 1711 break; 1712 } 1713 } 1714 if (newObject) 1715 { 1716 obj3.initShipmentsRelatedByRecipientId(); 1717 obj3.addShipmentRelatedByRecipientId(obj1); 1718 } 1719 1720 1721 1722 1723 omClass = ProjectPeer.getOMClass(); 1724 Project obj4 = (Project)ProjectPeer 1725 .row2Object( row, offset4, omClass); 1726 1727 newObject = true; 1728 for (int j = 0; j < results.size(); j++) 1729 { 1730 Shipment temp_obj1 = (Shipment)results.get(j); 1731 Project temp_obj4 = (Project)temp_obj1.getProject(); 1732 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1733 { 1734 newObject = false; 1735 temp_obj4.addShipment(obj1); 1736 break; 1737 } 1738 } 1739 if (newObject) 1740 { 1741 obj4.initShipments(); 1742 obj4.addShipment(obj1); 1743 } 1744 1745 1746 1747 1748 1749 omClass = CarrierPeer.getOMClass(); 1750 Carrier obj5 = (Carrier)CarrierPeer 1751 .row2Object( row, offset5, omClass); 1752 1753 newObject = true; 1754 for (int j = 0; j < results.size(); j++) 1755 { 1756 Shipment temp_obj1 = (Shipment)results.get(j); 1757 Carrier temp_obj5 = (Carrier)temp_obj1.getCarrier(); 1758 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1759 { 1760 newObject = false; 1761 temp_obj5.addShipment(obj1); 1762 break; 1763 } 1764 } 1765 if (newObject) 1766 { 1767 obj5.initShipments(); 1768 obj5.addShipment(obj1); 1769 } 1770 results.add(obj1); 1771 } 1772 return results; 1773 } 1774 1775 1776 1777 1778 1779 1790 protected static List doSelectJoinAllExceptCarrier(Criteria criteria) 1791 throws TorqueException 1792 { 1793 setDbName(criteria); 1794 1795 addSelectColumns(criteria); 1796 int offset2 = numColumns + 1; 1797 1798 CustomerPeer.addSelectColumns(criteria); 1799 int offset3 = offset2 + CustomerPeer.numColumns; 1800 1801 CustomerPeer.addSelectColumns(criteria); 1802 int offset4 = offset3 + CustomerPeer.numColumns; 1803 1804 ProjectPeer.addSelectColumns(criteria); 1805 int offset5 = offset4 + ProjectPeer.numColumns; 1806 1807 SorderPeer.addSelectColumns(criteria); 1808 int offset6 = offset5 + SorderPeer.numColumns; 1809 1810 1811 List rows = BasePeer.doSelect(criteria); 1812 List results = new ArrayList (); 1813 1814 for (int i = 0; i < rows.size(); i++) 1815 { 1816 Record row = (Record)rows.get(i); 1817 1818 Class omClass = ShipmentPeer.getOMClass(); 1819 Shipment obj1 = (Shipment)ShipmentPeer 1820 .row2Object(row, 1, omClass); 1821 1822 1823 1824 1825 omClass = CustomerPeer.getOMClass(); 1826 Customer obj2 = (Customer)CustomerPeer 1827 .row2Object( row, offset2, omClass); 1828 1829 boolean newObject = true; 1830 for (int j = 0; j < results.size(); j++) 1831 { 1832 Shipment temp_obj1 = (Shipment)results.get(j); 1833 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 1834 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1835 { 1836 newObject = false; 1837 temp_obj2.addShipmentRelatedByCustomerId(obj1); 1838 break; 1839 } 1840 } 1841 if (newObject) 1842 { 1843 obj2.initShipmentsRelatedByCustomerId(); 1844 obj2.addShipmentRelatedByCustomerId(obj1); 1845 } 1846 1847 1848 1849 1850 omClass = CustomerPeer.getOMClass(); 1851 Customer obj3 = (Customer)CustomerPeer 1852 .row2Object( row, offset3, omClass); 1853 1854 newObject = true; 1855 for (int j = 0; j < results.size(); j++) 1856 { 1857 Shipment temp_obj1 = (Shipment)results.get(j); 1858 Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 1859 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1860 { 1861 newObject = false; 1862 temp_obj3.addShipmentRelatedByRecipientId(obj1); 1863 break; 1864 } 1865 } 1866 if (newObject) 1867 { 1868 obj3.initShipmentsRelatedByRecipientId(); 1869 obj3.addShipmentRelatedByRecipientId(obj1); 1870 } 1871 1872 1873 1874 1875 omClass = ProjectPeer.getOMClass(); 1876 Project obj4 = (Project)ProjectPeer 1877 .row2Object( row, offset4, omClass); 1878 1879 newObject = true; 1880 for (int j = 0; j < results.size(); j++) 1881 { 1882 Shipment temp_obj1 = (Shipment)results.get(j); 1883 Project temp_obj4 = (Project)temp_obj1.getProject(); 1884 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1885 { 1886 newObject = false; 1887 temp_obj4.addShipment(obj1); 1888 break; 1889 } 1890 } 1891 if (newObject) 1892 { 1893 obj4.initShipments(); 1894 obj4.addShipment(obj1); 1895 } 1896 1897 1898 1899 1900 omClass = SorderPeer.getOMClass(); 1901 Sorder obj5 = (Sorder)SorderPeer 1902 .row2Object( row, offset5, omClass); 1903 1904 newObject = true; 1905 for (int j = 0; j < results.size(); j++) 1906 { 1907 Shipment temp_obj1 = (Shipment)results.get(j); 1908 Sorder temp_obj5 = (Sorder)temp_obj1.getSorder(); 1909 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1910 { 1911 newObject = false; 1912 temp_obj5.addShipment(obj1); 1913 break; 1914 } 1915 } 1916 if (newObject) 1917 { 1918 obj5.initShipments(); 1919 obj5.addShipment(obj1); 1920 } 1921 1922 results.add(obj1); 1923 } 1924 return results; 1925 } 1926 1927 1928 1935 protected static TableMap getTableMap() 1936 throws TorqueException 1937 { 1938 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1939 } 1940 1941 private static void setDbName(Criteria crit) 1942 { 1943 if (crit.getDbName() == Torque.getDefaultDB()) 1947 { 1948 crit.setDbName(DATABASE_NAME); 1949 } 1950 } 1951} 1952
| Popular Tags
|