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 44 public abstract class BasePaymentPeer 45 extends BasePeer 46 { 47 48 49 public static final String DATABASE_NAME = "cream"; 50 51 52 public static final String TABLE_NAME = "PAYMENT"; 53 54 59 public static MapBuilder getMapBuilder() 60 throws TorqueException 61 { 62 return getMapBuilder(PaymentMapBuilder.CLASS_NAME); 63 } 64 65 66 public static final String PAYMENT_ID; 67 68 public static final String PAYMENT_CODE; 69 70 public static final String STATUS; 71 72 public static final String PRIORITY; 73 74 public static final String ISSUED_DATE; 75 76 public static final String CLOSED_DATE; 77 78 public static final String CUSTOMER_ID; 79 80 public static final String PROJECT_ID; 81 82 public static final String SORDER_ID; 83 84 public static final String INVOICE_CODE; 85 86 public static final String PAY_TERM; 87 88 public static final String PAY_METHOD; 89 90 public static final String CURRENCY_ID; 91 92 public static final String CURRENCY_RATE; 93 94 public static final String CURRENCY_AMOUNT; 95 96 public static final String TOTAL_AMOUNT; 97 98 public static final String SUBJECT; 99 100 public static final String NOTES; 101 102 public static final String CREATED; 103 104 public static final String MODIFIED; 105 106 public static final String CREATED_BY; 107 108 public static final String MODIFIED_BY; 109 110 static 111 { 112 PAYMENT_ID = "PAYMENT.PAYMENT_ID"; 113 PAYMENT_CODE = "PAYMENT.PAYMENT_CODE"; 114 STATUS = "PAYMENT.STATUS"; 115 PRIORITY = "PAYMENT.PRIORITY"; 116 ISSUED_DATE = "PAYMENT.ISSUED_DATE"; 117 CLOSED_DATE = "PAYMENT.CLOSED_DATE"; 118 CUSTOMER_ID = "PAYMENT.CUSTOMER_ID"; 119 PROJECT_ID = "PAYMENT.PROJECT_ID"; 120 SORDER_ID = "PAYMENT.SORDER_ID"; 121 INVOICE_CODE = "PAYMENT.INVOICE_CODE"; 122 PAY_TERM = "PAYMENT.PAY_TERM"; 123 PAY_METHOD = "PAYMENT.PAY_METHOD"; 124 CURRENCY_ID = "PAYMENT.CURRENCY_ID"; 125 CURRENCY_RATE = "PAYMENT.CURRENCY_RATE"; 126 CURRENCY_AMOUNT = "PAYMENT.CURRENCY_AMOUNT"; 127 TOTAL_AMOUNT = "PAYMENT.TOTAL_AMOUNT"; 128 SUBJECT = "PAYMENT.SUBJECT"; 129 NOTES = "PAYMENT.NOTES"; 130 CREATED = "PAYMENT.CREATED"; 131 MODIFIED = "PAYMENT.MODIFIED"; 132 CREATED_BY = "PAYMENT.CREATED_BY"; 133 MODIFIED_BY = "PAYMENT.MODIFIED_BY"; 134 if (Torque.isInit()) 135 { 136 try 137 { 138 getMapBuilder(PaymentMapBuilder.CLASS_NAME); 139 } 140 catch (Exception e) 141 { 142 log.error("Could not initialize Peer", e); 143 } 144 } 145 else 146 { 147 Torque.registerMapBuilder(PaymentMapBuilder.CLASS_NAME); 148 } 149 } 150 151 152 public static final int numColumns = 22; 153 154 155 protected static final String CLASSNAME_DEFAULT = 156 "org.campware.cream.om.Payment"; 157 158 159 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 160 161 167 private static Class initClass(String className) 168 { 169 Class c = null; 170 try 171 { 172 c = Class.forName(className); 173 } 174 catch (Throwable t) 175 { 176 log.error("A FATAL ERROR has occurred which should not " 177 + "have happened under any circumstance. Please notify " 178 + "the Torque developers <torque-dev@db.apache.org> " 179 + "and give as many details as possible (including the error " 180 + "stack trace).", t); 181 182 if (t instanceof Error ) 184 { 185 throw (Error ) t.fillInStackTrace(); 186 } 187 } 188 return c; 189 } 190 191 201 public static List resultSet2Objects(java.sql.ResultSet results) 202 throws TorqueException 203 { 204 try 205 { 206 QueryDataSet qds = null; 207 List rows = null; 208 try 209 { 210 qds = new QueryDataSet(results); 211 rows = getSelectResults(qds); 212 } 213 finally 214 { 215 if (qds != null) 216 { 217 qds.close(); 218 } 219 } 220 221 return populateObjects(rows); 222 } 223 catch (SQLException e) 224 { 225 throw new TorqueException(e); 226 } 227 catch (DataSetException e) 228 { 229 throw new TorqueException(e); 230 } 231 } 232 233 234 235 242 public static ObjectKey doInsert(Criteria criteria) 243 throws TorqueException 244 { 245 return BasePaymentPeer 246 .doInsert(criteria, (Connection ) null); 247 } 248 249 259 public static ObjectKey doInsert(Criteria criteria, Connection con) 260 throws TorqueException 261 { 262 263 setDbName(criteria); 264 265 if (con == null) 266 { 267 return BasePeer.doInsert(criteria); 268 } 269 else 270 { 271 return BasePeer.doInsert(criteria, con); 272 } 273 } 274 275 282 public static void addSelectColumns(Criteria criteria) 283 throws TorqueException 284 { 285 criteria.addSelectColumn(PAYMENT_ID); 286 criteria.addSelectColumn(PAYMENT_CODE); 287 criteria.addSelectColumn(STATUS); 288 criteria.addSelectColumn(PRIORITY); 289 criteria.addSelectColumn(ISSUED_DATE); 290 criteria.addSelectColumn(CLOSED_DATE); 291 criteria.addSelectColumn(CUSTOMER_ID); 292 criteria.addSelectColumn(PROJECT_ID); 293 criteria.addSelectColumn(SORDER_ID); 294 criteria.addSelectColumn(INVOICE_CODE); 295 criteria.addSelectColumn(PAY_TERM); 296 criteria.addSelectColumn(PAY_METHOD); 297 criteria.addSelectColumn(CURRENCY_ID); 298 criteria.addSelectColumn(CURRENCY_RATE); 299 criteria.addSelectColumn(CURRENCY_AMOUNT); 300 criteria.addSelectColumn(TOTAL_AMOUNT); 301 criteria.addSelectColumn(SUBJECT); 302 criteria.addSelectColumn(NOTES); 303 criteria.addSelectColumn(CREATED); 304 criteria.addSelectColumn(MODIFIED); 305 criteria.addSelectColumn(CREATED_BY); 306 criteria.addSelectColumn(MODIFIED_BY); 307 } 308 309 318 public static Payment row2Object(Record row, 319 int offset, 320 Class cls) 321 throws TorqueException 322 { 323 try 324 { 325 Payment obj = (Payment) cls.newInstance(); 326 PaymentPeer.populateObject(row, offset, obj); 327 obj.setModified(false); 328 obj.setNew(false); 329 330 return obj; 331 } 332 catch (InstantiationException e) 333 { 334 throw new TorqueException(e); 335 } 336 catch (IllegalAccessException e) 337 { 338 throw new TorqueException(e); 339 } 340 } 341 342 351 public static void populateObject(Record row, 352 int offset, 353 Payment obj) 354 throws TorqueException 355 { 356 try 357 { 358 obj.setPaymentId(row.getValue(offset + 0).asInt()); 359 obj.setPaymentCode(row.getValue(offset + 1).asString()); 360 obj.setStatus(row.getValue(offset + 2).asInt()); 361 obj.setPriority(row.getValue(offset + 3).asInt()); 362 obj.setIssuedDate(row.getValue(offset + 4).asUtilDate()); 363 obj.setClosedDate(row.getValue(offset + 5).asUtilDate()); 364 obj.setCustomerId(row.getValue(offset + 6).asInt()); 365 obj.setProjectId(row.getValue(offset + 7).asInt()); 366 obj.setSorderId(row.getValue(offset + 8).asInt()); 367 obj.setInvoiceCode(row.getValue(offset + 9).asString()); 368 obj.setPayTerm(row.getValue(offset + 10).asInt()); 369 obj.setPayMethod(row.getValue(offset + 11).asInt()); 370 obj.setCurrencyId(row.getValue(offset + 12).asInt()); 371 obj.setCurrencyRate(row.getValue(offset + 13).asBigDecimal()); 372 obj.setCurrencyAmount(row.getValue(offset + 14).asBigDecimal()); 373 obj.setTotalAmount(row.getValue(offset + 15).asBigDecimal()); 374 obj.setSubject(row.getValue(offset + 16).asString()); 375 obj.setNotes(row.getValue(offset + 17).asString()); 376 obj.setCreated(row.getValue(offset + 18).asUtilDate()); 377 obj.setModified(row.getValue(offset + 19).asUtilDate()); 378 obj.setCreatedBy(row.getValue(offset + 20).asString()); 379 obj.setModifiedBy(row.getValue(offset + 21).asString()); 380 } 381 catch (DataSetException e) 382 { 383 throw new TorqueException(e); 384 } 385 } 386 387 395 public static List doSelect(Criteria criteria) throws TorqueException 396 { 397 return populateObjects(doSelectVillageRecords(criteria)); 398 } 399 400 409 public static List doSelect(Criteria criteria, Connection con) 410 throws TorqueException 411 { 412 return populateObjects(doSelectVillageRecords(criteria, con)); 413 } 414 415 425 public static List doSelectVillageRecords(Criteria criteria) 426 throws TorqueException 427 { 428 return BasePaymentPeer 429 .doSelectVillageRecords(criteria, (Connection ) null); 430 } 431 432 441 public static List doSelectVillageRecords(Criteria criteria, Connection con) 442 throws TorqueException 443 { 444 if (criteria.getSelectColumns().size() == 0) 445 { 446 addSelectColumns(criteria); 447 } 448 449 450 setDbName(criteria); 451 452 if (con == null) 455 { 456 return BasePeer.doSelect(criteria); 457 } 458 else 459 { 460 return BasePeer.doSelect(criteria, con); 461 } 462 } 463 464 471 public static List populateObjects(List records) 472 throws TorqueException 473 { 474 List results = new ArrayList (records.size()); 475 476 for (int i = 0; i < records.size(); i++) 478 { 479 Record row = (Record) records.get(i); 480 results.add(PaymentPeer.row2Object(row, 1, 481 PaymentPeer.getOMClass())); 482 } 483 return results; 484 } 485 486 487 495 public static Class getOMClass() 496 throws TorqueException 497 { 498 return CLASS_DEFAULT; 499 } 500 501 509 public static void doUpdate(Criteria criteria) throws TorqueException 510 { 511 BasePaymentPeer 512 .doUpdate(criteria, (Connection ) null); 513 } 514 515 526 public static void doUpdate(Criteria criteria, Connection con) 527 throws TorqueException 528 { 529 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 530 selectCriteria.put(PAYMENT_ID, criteria.remove(PAYMENT_ID)); 531 532 setDbName(criteria); 533 534 if (con == null) 535 { 536 BasePeer.doUpdate(selectCriteria, criteria); 537 } 538 else 539 { 540 BasePeer.doUpdate(selectCriteria, criteria, con); 541 } 542 } 543 544 551 public static void doDelete(Criteria criteria) throws TorqueException 552 { 553 PaymentPeer 554 .doDelete(criteria, (Connection ) null); 555 } 556 557 567 public static void doDelete(Criteria criteria, Connection con) 568 throws TorqueException 569 { 570 571 setDbName(criteria); 572 573 if (con == null) 574 { 575 BasePeer.doDelete(criteria); 576 } 577 else 578 { 579 BasePeer.doDelete(criteria, con); 580 } 581 } 582 583 589 public static List doSelect(Payment obj) throws TorqueException 590 { 591 return doSelect(buildSelectCriteria(obj)); 592 } 593 594 600 public static void doInsert(Payment obj) throws TorqueException 601 { 602 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 603 obj.setNew(false); 604 obj.setModified(false); 605 } 606 607 612 public static void doUpdate(Payment obj) throws TorqueException 613 { 614 doUpdate(buildCriteria(obj)); 615 obj.setModified(false); 616 } 617 618 623 public static void doDelete(Payment obj) throws TorqueException 624 { 625 doDelete(buildSelectCriteria(obj)); 626 } 627 628 638 public static void doInsert(Payment obj, Connection con) 639 throws TorqueException 640 { 641 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 642 obj.setNew(false); 643 obj.setModified(false); 644 } 645 646 656 public static void doUpdate(Payment obj, Connection con) 657 throws TorqueException 658 { 659 doUpdate(buildCriteria(obj), con); 660 obj.setModified(false); 661 } 662 663 673 public static void doDelete(Payment obj, Connection con) 674 throws TorqueException 675 { 676 doDelete(buildSelectCriteria(obj), con); 677 } 678 679 686 public static void doDelete(ObjectKey pk) throws TorqueException 687 { 688 BasePaymentPeer 689 .doDelete(pk, (Connection ) null); 690 } 691 692 702 public static void doDelete(ObjectKey pk, Connection con) 703 throws TorqueException 704 { 705 doDelete(buildCriteria(pk), con); 706 } 707 708 709 public static Criteria buildCriteria( ObjectKey pk ) 710 { 711 Criteria criteria = new Criteria(); 712 criteria.add(PAYMENT_ID, pk); 713 return criteria; 714 } 715 716 717 public static Criteria buildCriteria( Payment obj ) 718 { 719 Criteria criteria = new Criteria(DATABASE_NAME); 720 if (!obj.isNew()) 721 criteria.add(PAYMENT_ID, obj.getPaymentId()); 722 criteria.add(PAYMENT_CODE, obj.getPaymentCode()); 723 criteria.add(STATUS, obj.getStatus()); 724 criteria.add(PRIORITY, obj.getPriority()); 725 criteria.add(ISSUED_DATE, obj.getIssuedDate()); 726 criteria.add(CLOSED_DATE, obj.getClosedDate()); 727 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 728 criteria.add(PROJECT_ID, obj.getProjectId()); 729 criteria.add(SORDER_ID, obj.getSorderId()); 730 criteria.add(INVOICE_CODE, obj.getInvoiceCode()); 731 criteria.add(PAY_TERM, obj.getPayTerm()); 732 criteria.add(PAY_METHOD, obj.getPayMethod()); 733 criteria.add(CURRENCY_ID, obj.getCurrencyId()); 734 criteria.add(CURRENCY_RATE, obj.getCurrencyRate()); 735 criteria.add(CURRENCY_AMOUNT, obj.getCurrencyAmount()); 736 criteria.add(TOTAL_AMOUNT, obj.getTotalAmount()); 737 criteria.add(SUBJECT, obj.getSubject()); 738 criteria.add(NOTES, obj.getNotes()); 739 criteria.add(CREATED, obj.getCreated()); 740 criteria.add(MODIFIED, obj.getModified()); 741 criteria.add(CREATED_BY, obj.getCreatedBy()); 742 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 743 return criteria; 744 } 745 746 747 public static Criteria buildSelectCriteria( Payment obj ) 748 { 749 Criteria criteria = new Criteria(DATABASE_NAME); 750 if (!obj.isNew()) 751 criteria.add(PAYMENT_ID, obj.getPaymentId()); 752 criteria.add(PAYMENT_CODE, obj.getPaymentCode()); 753 criteria.add(STATUS, obj.getStatus()); 754 criteria.add(PRIORITY, obj.getPriority()); 755 criteria.add(ISSUED_DATE, obj.getIssuedDate()); 756 criteria.add(CLOSED_DATE, obj.getClosedDate()); 757 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 758 criteria.add(PROJECT_ID, obj.getProjectId()); 759 criteria.add(SORDER_ID, obj.getSorderId()); 760 criteria.add(INVOICE_CODE, obj.getInvoiceCode()); 761 criteria.add(PAY_TERM, obj.getPayTerm()); 762 criteria.add(PAY_METHOD, obj.getPayMethod()); 763 criteria.add(CURRENCY_ID, obj.getCurrencyId()); 764 criteria.add(CURRENCY_RATE, obj.getCurrencyRate()); 765 criteria.add(CURRENCY_AMOUNT, obj.getCurrencyAmount()); 766 criteria.add(TOTAL_AMOUNT, obj.getTotalAmount()); 767 criteria.add(SUBJECT, obj.getSubject()); 768 criteria.add(NOTES, obj.getNotes()); 769 criteria.add(CREATED, obj.getCreated()); 770 criteria.add(MODIFIED, obj.getModified()); 771 criteria.add(CREATED_BY, obj.getCreatedBy()); 772 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 773 return criteria; 774 } 775 776 777 786 public static Payment retrieveByPK(int pk) 787 throws TorqueException, NoRowsException, TooManyRowsException 788 { 789 return retrieveByPK(SimpleKey.keyFor(pk)); 790 } 791 792 802 public static Payment retrieveByPK(int pk, Connection con) 803 throws TorqueException, NoRowsException, TooManyRowsException 804 { 805 return retrieveByPK(SimpleKey.keyFor(pk), con); 806 } 807 808 817 public static Payment retrieveByPK(ObjectKey pk) 818 throws TorqueException, NoRowsException, TooManyRowsException 819 { 820 Connection db = null; 821 Payment retVal = null; 822 try 823 { 824 db = Torque.getConnection(DATABASE_NAME); 825 retVal = retrieveByPK(pk, db); 826 } 827 finally 828 { 829 Torque.closeConnection(db); 830 } 831 return(retVal); 832 } 833 834 844 public static Payment retrieveByPK(ObjectKey pk, Connection con) 845 throws TorqueException, NoRowsException, TooManyRowsException 846 { 847 Criteria criteria = buildCriteria(pk); 848 List v = doSelect(criteria, con); 849 if (v.size() == 0) 850 { 851 throw new NoRowsException("Failed to select a row."); 852 } 853 else if (v.size() > 1) 854 { 855 throw new TooManyRowsException("Failed to select only one row."); 856 } 857 else 858 { 859 return (Payment)v.get(0); 860 } 861 } 862 863 870 public static List retrieveByPKs(List pks) 871 throws TorqueException 872 { 873 Connection db = null; 874 List retVal = null; 875 try 876 { 877 db = Torque.getConnection(DATABASE_NAME); 878 retVal = retrieveByPKs(pks, db); 879 } 880 finally 881 { 882 Torque.closeConnection(db); 883 } 884 return(retVal); 885 } 886 887 895 public static List retrieveByPKs( List pks, Connection dbcon ) 896 throws TorqueException 897 { 898 List objs = null; 899 if (pks == null || pks.size() == 0) 900 { 901 objs = new LinkedList (); 902 } 903 else 904 { 905 Criteria criteria = new Criteria(); 906 criteria.addIn( PAYMENT_ID, pks ); 907 objs = doSelect(criteria, dbcon); 908 } 909 return objs; 910 } 911 912 913 914 915 916 917 918 919 920 921 932 protected static List doSelectJoinCustomer(Criteria criteria) 933 throws TorqueException 934 { 935 setDbName(criteria); 936 937 PaymentPeer.addSelectColumns(criteria); 938 int offset = numColumns + 1; 939 CustomerPeer.addSelectColumns(criteria); 940 941 942 criteria.addJoin(PaymentPeer.CUSTOMER_ID, 943 CustomerPeer.CUSTOMER_ID); 944 945 946 947 List rows = BasePeer.doSelect(criteria); 948 List results = new ArrayList (); 949 950 for (int i = 0; i < rows.size(); i++) 951 { 952 Record row = (Record) rows.get(i); 953 954 Class omClass = PaymentPeer.getOMClass(); 955 Payment obj1 = (Payment) PaymentPeer 956 .row2Object(row, 1, omClass); 957 omClass = CustomerPeer.getOMClass(); 958 Customer obj2 = (Customer)CustomerPeer 959 .row2Object(row, offset, omClass); 960 961 boolean newObject = true; 962 for (int j = 0; j < results.size(); j++) 963 { 964 Payment temp_obj1 = (Payment)results.get(j); 965 Customer temp_obj2 = (Customer)temp_obj1.getCustomer(); 966 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 967 { 968 newObject = false; 969 temp_obj2.addPayment(obj1); 970 break; 971 } 972 } 973 if (newObject) 974 { 975 obj2.initPayments(); 976 obj2.addPayment(obj1); 977 } 978 results.add(obj1); 979 } 980 return results; 981 } 982 983 984 985 986 997 protected static List doSelectJoinProject(Criteria criteria) 998 throws TorqueException 999 { 1000 setDbName(criteria); 1001 1002 PaymentPeer.addSelectColumns(criteria); 1003 int offset = numColumns + 1; 1004 ProjectPeer.addSelectColumns(criteria); 1005 1006 1007 criteria.addJoin(PaymentPeer.PROJECT_ID, 1008 ProjectPeer.PROJECT_ID); 1009 1010 1011 1012 List rows = BasePeer.doSelect(criteria); 1013 List results = new ArrayList (); 1014 1015 for (int i = 0; i < rows.size(); i++) 1016 { 1017 Record row = (Record) rows.get(i); 1018 1019 Class omClass = PaymentPeer.getOMClass(); 1020 Payment obj1 = (Payment) PaymentPeer 1021 .row2Object(row, 1, omClass); 1022 omClass = ProjectPeer.getOMClass(); 1023 Project obj2 = (Project)ProjectPeer 1024 .row2Object(row, offset, omClass); 1025 1026 boolean newObject = true; 1027 for (int j = 0; j < results.size(); j++) 1028 { 1029 Payment temp_obj1 = (Payment)results.get(j); 1030 Project temp_obj2 = (Project)temp_obj1.getProject(); 1031 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1032 { 1033 newObject = false; 1034 temp_obj2.addPayment(obj1); 1035 break; 1036 } 1037 } 1038 if (newObject) 1039 { 1040 obj2.initPayments(); 1041 obj2.addPayment(obj1); 1042 } 1043 results.add(obj1); 1044 } 1045 return results; 1046 } 1047 1048 1049 1050 1051 1062 protected static List doSelectJoinSorder(Criteria criteria) 1063 throws TorqueException 1064 { 1065 setDbName(criteria); 1066 1067 PaymentPeer.addSelectColumns(criteria); 1068 int offset = numColumns + 1; 1069 SorderPeer.addSelectColumns(criteria); 1070 1071 1072 criteria.addJoin(PaymentPeer.SORDER_ID, 1073 SorderPeer.SORDER_ID); 1074 1075 1076 1077 List rows = BasePeer.doSelect(criteria); 1078 List results = new ArrayList (); 1079 1080 for (int i = 0; i < rows.size(); i++) 1081 { 1082 Record row = (Record) rows.get(i); 1083 1084 Class omClass = PaymentPeer.getOMClass(); 1085 Payment obj1 = (Payment) PaymentPeer 1086 .row2Object(row, 1, omClass); 1087 omClass = SorderPeer.getOMClass(); 1088 Sorder obj2 = (Sorder)SorderPeer 1089 .row2Object(row, offset, omClass); 1090 1091 boolean newObject = true; 1092 for (int j = 0; j < results.size(); j++) 1093 { 1094 Payment temp_obj1 = (Payment)results.get(j); 1095 Sorder temp_obj2 = (Sorder)temp_obj1.getSorder(); 1096 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1097 { 1098 newObject = false; 1099 temp_obj2.addPayment(obj1); 1100 break; 1101 } 1102 } 1103 if (newObject) 1104 { 1105 obj2.initPayments(); 1106 obj2.addPayment(obj1); 1107 } 1108 results.add(obj1); 1109 } 1110 return results; 1111 } 1112 1113 1114 1115 1116 1127 protected static List doSelectJoinCurrency(Criteria criteria) 1128 throws TorqueException 1129 { 1130 setDbName(criteria); 1131 1132 PaymentPeer.addSelectColumns(criteria); 1133 int offset = numColumns + 1; 1134 CurrencyPeer.addSelectColumns(criteria); 1135 1136 1137 criteria.addJoin(PaymentPeer.CURRENCY_ID, 1138 CurrencyPeer.CURRENCY_ID); 1139 1140 1141 1142 List rows = BasePeer.doSelect(criteria); 1143 List results = new ArrayList (); 1144 1145 for (int i = 0; i < rows.size(); i++) 1146 { 1147 Record row = (Record) rows.get(i); 1148 1149 Class omClass = PaymentPeer.getOMClass(); 1150 Payment obj1 = (Payment) PaymentPeer 1151 .row2Object(row, 1, omClass); 1152 omClass = CurrencyPeer.getOMClass(); 1153 Currency obj2 = (Currency)CurrencyPeer 1154 .row2Object(row, offset, omClass); 1155 1156 boolean newObject = true; 1157 for (int j = 0; j < results.size(); j++) 1158 { 1159 Payment temp_obj1 = (Payment)results.get(j); 1160 Currency temp_obj2 = (Currency)temp_obj1.getCurrency(); 1161 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1162 { 1163 newObject = false; 1164 temp_obj2.addPayment(obj1); 1165 break; 1166 } 1167 } 1168 if (newObject) 1169 { 1170 obj2.initPayments(); 1171 obj2.addPayment(obj1); 1172 } 1173 results.add(obj1); 1174 } 1175 return results; 1176 } 1177 1178 1179 1180 1181 1182 1183 1184 1185 1196 protected static List doSelectJoinAllExceptCustomer(Criteria criteria) 1197 throws TorqueException 1198 { 1199 setDbName(criteria); 1200 1201 addSelectColumns(criteria); 1202 int offset2 = numColumns + 1; 1203 1204 1205 ProjectPeer.addSelectColumns(criteria); 1206 int offset3 = offset2 + ProjectPeer.numColumns; 1207 1208 SorderPeer.addSelectColumns(criteria); 1209 int offset4 = offset3 + SorderPeer.numColumns; 1210 1211 CurrencyPeer.addSelectColumns(criteria); 1212 int offset5 = offset4 + CurrencyPeer.numColumns; 1213 1214 List rows = BasePeer.doSelect(criteria); 1215 List results = new ArrayList (); 1216 1217 for (int i = 0; i < rows.size(); i++) 1218 { 1219 Record row = (Record)rows.get(i); 1220 1221 Class omClass = PaymentPeer.getOMClass(); 1222 Payment obj1 = (Payment)PaymentPeer 1223 .row2Object(row, 1, omClass); 1224 1225 1226 1227 1228 1229 omClass = ProjectPeer.getOMClass(); 1230 Project obj2 = (Project)ProjectPeer 1231 .row2Object( row, offset2, omClass); 1232 1233 boolean newObject = true; 1234 for (int j = 0; j < results.size(); j++) 1235 { 1236 Payment temp_obj1 = (Payment)results.get(j); 1237 Project temp_obj2 = (Project)temp_obj1.getProject(); 1238 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1239 { 1240 newObject = false; 1241 temp_obj2.addPayment(obj1); 1242 break; 1243 } 1244 } 1245 if (newObject) 1246 { 1247 obj2.initPayments(); 1248 obj2.addPayment(obj1); 1249 } 1250 1251 1252 1253 1254 omClass = SorderPeer.getOMClass(); 1255 Sorder obj3 = (Sorder)SorderPeer 1256 .row2Object( row, offset3, omClass); 1257 1258 newObject = true; 1259 for (int j = 0; j < results.size(); j++) 1260 { 1261 Payment temp_obj1 = (Payment)results.get(j); 1262 Sorder temp_obj3 = (Sorder)temp_obj1.getSorder(); 1263 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1264 { 1265 newObject = false; 1266 temp_obj3.addPayment(obj1); 1267 break; 1268 } 1269 } 1270 if (newObject) 1271 { 1272 obj3.initPayments(); 1273 obj3.addPayment(obj1); 1274 } 1275 1276 1277 1278 1279 omClass = CurrencyPeer.getOMClass(); 1280 Currency obj4 = (Currency)CurrencyPeer 1281 .row2Object( row, offset4, omClass); 1282 1283 newObject = true; 1284 for (int j = 0; j < results.size(); j++) 1285 { 1286 Payment temp_obj1 = (Payment)results.get(j); 1287 Currency temp_obj4 = (Currency)temp_obj1.getCurrency(); 1288 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1289 { 1290 newObject = false; 1291 temp_obj4.addPayment(obj1); 1292 break; 1293 } 1294 } 1295 if (newObject) 1296 { 1297 obj4.initPayments(); 1298 obj4.addPayment(obj1); 1299 } 1300 results.add(obj1); 1301 } 1302 return results; 1303 } 1304 1305 1306 1307 1308 1309 1320 protected static List doSelectJoinAllExceptProject(Criteria criteria) 1321 throws TorqueException 1322 { 1323 setDbName(criteria); 1324 1325 addSelectColumns(criteria); 1326 int offset2 = numColumns + 1; 1327 1328 CustomerPeer.addSelectColumns(criteria); 1329 int offset3 = offset2 + CustomerPeer.numColumns; 1330 1331 1332 SorderPeer.addSelectColumns(criteria); 1333 int offset4 = offset3 + SorderPeer.numColumns; 1334 1335 CurrencyPeer.addSelectColumns(criteria); 1336 int offset5 = offset4 + CurrencyPeer.numColumns; 1337 1338 List rows = BasePeer.doSelect(criteria); 1339 List results = new ArrayList (); 1340 1341 for (int i = 0; i < rows.size(); i++) 1342 { 1343 Record row = (Record)rows.get(i); 1344 1345 Class omClass = PaymentPeer.getOMClass(); 1346 Payment obj1 = (Payment)PaymentPeer 1347 .row2Object(row, 1, omClass); 1348 1349 1350 1351 1352 omClass = CustomerPeer.getOMClass(); 1353 Customer obj2 = (Customer)CustomerPeer 1354 .row2Object( row, offset2, omClass); 1355 1356 boolean newObject = true; 1357 for (int j = 0; j < results.size(); j++) 1358 { 1359 Payment temp_obj1 = (Payment)results.get(j); 1360 Customer temp_obj2 = (Customer)temp_obj1.getCustomer(); 1361 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1362 { 1363 newObject = false; 1364 temp_obj2.addPayment(obj1); 1365 break; 1366 } 1367 } 1368 if (newObject) 1369 { 1370 obj2.initPayments(); 1371 obj2.addPayment(obj1); 1372 } 1373 1374 1375 1376 1377 1378 omClass = SorderPeer.getOMClass(); 1379 Sorder obj3 = (Sorder)SorderPeer 1380 .row2Object( row, offset3, omClass); 1381 1382 newObject = true; 1383 for (int j = 0; j < results.size(); j++) 1384 { 1385 Payment temp_obj1 = (Payment)results.get(j); 1386 Sorder temp_obj3 = (Sorder)temp_obj1.getSorder(); 1387 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1388 { 1389 newObject = false; 1390 temp_obj3.addPayment(obj1); 1391 break; 1392 } 1393 } 1394 if (newObject) 1395 { 1396 obj3.initPayments(); 1397 obj3.addPayment(obj1); 1398 } 1399 1400 1401 1402 1403 omClass = CurrencyPeer.getOMClass(); 1404 Currency obj4 = (Currency)CurrencyPeer 1405 .row2Object( row, offset4, omClass); 1406 1407 newObject = true; 1408 for (int j = 0; j < results.size(); j++) 1409 { 1410 Payment temp_obj1 = (Payment)results.get(j); 1411 Currency temp_obj4 = (Currency)temp_obj1.getCurrency(); 1412 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1413 { 1414 newObject = false; 1415 temp_obj4.addPayment(obj1); 1416 break; 1417 } 1418 } 1419 if (newObject) 1420 { 1421 obj4.initPayments(); 1422 obj4.addPayment(obj1); 1423 } 1424 results.add(obj1); 1425 } 1426 return results; 1427 } 1428 1429 1430 1431 1432 1433 1444 protected static List doSelectJoinAllExceptSorder(Criteria criteria) 1445 throws TorqueException 1446 { 1447 setDbName(criteria); 1448 1449 addSelectColumns(criteria); 1450 int offset2 = numColumns + 1; 1451 1452 CustomerPeer.addSelectColumns(criteria); 1453 int offset3 = offset2 + CustomerPeer.numColumns; 1454 1455 ProjectPeer.addSelectColumns(criteria); 1456 int offset4 = offset3 + ProjectPeer.numColumns; 1457 1458 1459 CurrencyPeer.addSelectColumns(criteria); 1460 int offset5 = offset4 + CurrencyPeer.numColumns; 1461 1462 List rows = BasePeer.doSelect(criteria); 1463 List results = new ArrayList (); 1464 1465 for (int i = 0; i < rows.size(); i++) 1466 { 1467 Record row = (Record)rows.get(i); 1468 1469 Class omClass = PaymentPeer.getOMClass(); 1470 Payment obj1 = (Payment)PaymentPeer 1471 .row2Object(row, 1, omClass); 1472 1473 1474 1475 1476 omClass = CustomerPeer.getOMClass(); 1477 Customer obj2 = (Customer)CustomerPeer 1478 .row2Object( row, offset2, omClass); 1479 1480 boolean newObject = true; 1481 for (int j = 0; j < results.size(); j++) 1482 { 1483 Payment temp_obj1 = (Payment)results.get(j); 1484 Customer temp_obj2 = (Customer)temp_obj1.getCustomer(); 1485 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1486 { 1487 newObject = false; 1488 temp_obj2.addPayment(obj1); 1489 break; 1490 } 1491 } 1492 if (newObject) 1493 { 1494 obj2.initPayments(); 1495 obj2.addPayment(obj1); 1496 } 1497 1498 1499 1500 1501 omClass = ProjectPeer.getOMClass(); 1502 Project obj3 = (Project)ProjectPeer 1503 .row2Object( row, offset3, omClass); 1504 1505 newObject = true; 1506 for (int j = 0; j < results.size(); j++) 1507 { 1508 Payment temp_obj1 = (Payment)results.get(j); 1509 Project temp_obj3 = (Project)temp_obj1.getProject(); 1510 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1511 { 1512 newObject = false; 1513 temp_obj3.addPayment(obj1); 1514 break; 1515 } 1516 } 1517 if (newObject) 1518 { 1519 obj3.initPayments(); 1520 obj3.addPayment(obj1); 1521 } 1522 1523 1524 1525 1526 1527 omClass = CurrencyPeer.getOMClass(); 1528 Currency obj4 = (Currency)CurrencyPeer 1529 .row2Object( row, offset4, omClass); 1530 1531 newObject = true; 1532 for (int j = 0; j < results.size(); j++) 1533 { 1534 Payment temp_obj1 = (Payment)results.get(j); 1535 Currency temp_obj4 = (Currency)temp_obj1.getCurrency(); 1536 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1537 { 1538 newObject = false; 1539 temp_obj4.addPayment(obj1); 1540 break; 1541 } 1542 } 1543 if (newObject) 1544 { 1545 obj4.initPayments(); 1546 obj4.addPayment(obj1); 1547 } 1548 results.add(obj1); 1549 } 1550 return results; 1551 } 1552 1553 1554 1555 1556 1557 1568 protected static List doSelectJoinAllExceptCurrency(Criteria criteria) 1569 throws TorqueException 1570 { 1571 setDbName(criteria); 1572 1573 addSelectColumns(criteria); 1574 int offset2 = numColumns + 1; 1575 1576 CustomerPeer.addSelectColumns(criteria); 1577 int offset3 = offset2 + CustomerPeer.numColumns; 1578 1579 ProjectPeer.addSelectColumns(criteria); 1580 int offset4 = offset3 + ProjectPeer.numColumns; 1581 1582 SorderPeer.addSelectColumns(criteria); 1583 int offset5 = offset4 + SorderPeer.numColumns; 1584 1585 1586 List rows = BasePeer.doSelect(criteria); 1587 List results = new ArrayList (); 1588 1589 for (int i = 0; i < rows.size(); i++) 1590 { 1591 Record row = (Record)rows.get(i); 1592 1593 Class omClass = PaymentPeer.getOMClass(); 1594 Payment obj1 = (Payment)PaymentPeer 1595 .row2Object(row, 1, omClass); 1596 1597 1598 1599 1600 omClass = CustomerPeer.getOMClass(); 1601 Customer obj2 = (Customer)CustomerPeer 1602 .row2Object( row, offset2, omClass); 1603 1604 boolean newObject = true; 1605 for (int j = 0; j < results.size(); j++) 1606 { 1607 Payment temp_obj1 = (Payment)results.get(j); 1608 Customer temp_obj2 = (Customer)temp_obj1.getCustomer(); 1609 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1610 { 1611 newObject = false; 1612 temp_obj2.addPayment(obj1); 1613 break; 1614 } 1615 } 1616 if (newObject) 1617 { 1618 obj2.initPayments(); 1619 obj2.addPayment(obj1); 1620 } 1621 1622 1623 1624 1625 omClass = ProjectPeer.getOMClass(); 1626 Project obj3 = (Project)ProjectPeer 1627 .row2Object( row, offset3, omClass); 1628 1629 newObject = true; 1630 for (int j = 0; j < results.size(); j++) 1631 { 1632 Payment temp_obj1 = (Payment)results.get(j); 1633 Project temp_obj3 = (Project)temp_obj1.getProject(); 1634 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1635 { 1636 newObject = false; 1637 temp_obj3.addPayment(obj1); 1638 break; 1639 } 1640 } 1641 if (newObject) 1642 { 1643 obj3.initPayments(); 1644 obj3.addPayment(obj1); 1645 } 1646 1647 1648 1649 1650 omClass = SorderPeer.getOMClass(); 1651 Sorder obj4 = (Sorder)SorderPeer 1652 .row2Object( row, offset4, omClass); 1653 1654 newObject = true; 1655 for (int j = 0; j < results.size(); j++) 1656 { 1657 Payment temp_obj1 = (Payment)results.get(j); 1658 Sorder temp_obj4 = (Sorder)temp_obj1.getSorder(); 1659 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1660 { 1661 newObject = false; 1662 temp_obj4.addPayment(obj1); 1663 break; 1664 } 1665 } 1666 if (newObject) 1667 { 1668 obj4.initPayments(); 1669 obj4.addPayment(obj1); 1670 } 1671 1672 results.add(obj1); 1673 } 1674 return results; 1675 } 1676 1677 1678 1685 protected static TableMap getTableMap() 1686 throws TorqueException 1687 { 1688 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1689 } 1690 1691 private static void setDbName(Criteria crit) 1692 { 1693 if (crit.getDbName() == Torque.getDefaultDB()) 1697 { 1698 crit.setDbName(DATABASE_NAME); 1699 } 1700 } 1701} 1702
| Popular Tags
|