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 BaseServicePeer 45 extends BasePeer 46 { 47 48 49 public static final String DATABASE_NAME = "cream"; 50 51 52 public static final String TABLE_NAME = "SERVICE"; 53 54 59 public static MapBuilder getMapBuilder() 60 throws TorqueException 61 { 62 return getMapBuilder(ServiceMapBuilder.CLASS_NAME); 63 } 64 65 66 public static final String SERVICE_ID; 67 68 public static final String SERVICE_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 RECIPIENT_ID; 81 82 public static final String PROJECT_ID; 83 84 public static final String SORDER_ID; 85 86 public static final String INVOICE_CODE; 87 88 public static final String SUBJECT; 89 90 public static final String NOTES; 91 92 public static final String CREATED; 93 94 public static final String MODIFIED; 95 96 public static final String CREATED_BY; 97 98 public static final String MODIFIED_BY; 99 100 static 101 { 102 SERVICE_ID = "SERVICE.SERVICE_ID"; 103 SERVICE_CODE = "SERVICE.SERVICE_CODE"; 104 STATUS = "SERVICE.STATUS"; 105 PRIORITY = "SERVICE.PRIORITY"; 106 ISSUED_DATE = "SERVICE.ISSUED_DATE"; 107 CLOSED_DATE = "SERVICE.CLOSED_DATE"; 108 CUSTOMER_ID = "SERVICE.CUSTOMER_ID"; 109 RECIPIENT_ID = "SERVICE.RECIPIENT_ID"; 110 PROJECT_ID = "SERVICE.PROJECT_ID"; 111 SORDER_ID = "SERVICE.SORDER_ID"; 112 INVOICE_CODE = "SERVICE.INVOICE_CODE"; 113 SUBJECT = "SERVICE.SUBJECT"; 114 NOTES = "SERVICE.NOTES"; 115 CREATED = "SERVICE.CREATED"; 116 MODIFIED = "SERVICE.MODIFIED"; 117 CREATED_BY = "SERVICE.CREATED_BY"; 118 MODIFIED_BY = "SERVICE.MODIFIED_BY"; 119 if (Torque.isInit()) 120 { 121 try 122 { 123 getMapBuilder(ServiceMapBuilder.CLASS_NAME); 124 } 125 catch (Exception e) 126 { 127 log.error("Could not initialize Peer", e); 128 } 129 } 130 else 131 { 132 Torque.registerMapBuilder(ServiceMapBuilder.CLASS_NAME); 133 } 134 } 135 136 137 public static final int numColumns = 17; 138 139 140 protected static final String CLASSNAME_DEFAULT = 141 "org.campware.cream.om.Service"; 142 143 144 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 145 146 152 private static Class initClass(String className) 153 { 154 Class c = null; 155 try 156 { 157 c = Class.forName(className); 158 } 159 catch (Throwable t) 160 { 161 log.error("A FATAL ERROR has occurred which should not " 162 + "have happened under any circumstance. Please notify " 163 + "the Torque developers <torque-dev@db.apache.org> " 164 + "and give as many details as possible (including the error " 165 + "stack trace).", t); 166 167 if (t instanceof Error ) 169 { 170 throw (Error ) t.fillInStackTrace(); 171 } 172 } 173 return c; 174 } 175 176 186 public static List resultSet2Objects(java.sql.ResultSet results) 187 throws TorqueException 188 { 189 try 190 { 191 QueryDataSet qds = null; 192 List rows = null; 193 try 194 { 195 qds = new QueryDataSet(results); 196 rows = getSelectResults(qds); 197 } 198 finally 199 { 200 if (qds != null) 201 { 202 qds.close(); 203 } 204 } 205 206 return populateObjects(rows); 207 } 208 catch (SQLException e) 209 { 210 throw new TorqueException(e); 211 } 212 catch (DataSetException e) 213 { 214 throw new TorqueException(e); 215 } 216 } 217 218 219 220 227 public static ObjectKey doInsert(Criteria criteria) 228 throws TorqueException 229 { 230 return BaseServicePeer 231 .doInsert(criteria, (Connection ) null); 232 } 233 234 244 public static ObjectKey doInsert(Criteria criteria, Connection con) 245 throws TorqueException 246 { 247 248 setDbName(criteria); 249 250 if (con == null) 251 { 252 return BasePeer.doInsert(criteria); 253 } 254 else 255 { 256 return BasePeer.doInsert(criteria, con); 257 } 258 } 259 260 267 public static void addSelectColumns(Criteria criteria) 268 throws TorqueException 269 { 270 criteria.addSelectColumn(SERVICE_ID); 271 criteria.addSelectColumn(SERVICE_CODE); 272 criteria.addSelectColumn(STATUS); 273 criteria.addSelectColumn(PRIORITY); 274 criteria.addSelectColumn(ISSUED_DATE); 275 criteria.addSelectColumn(CLOSED_DATE); 276 criteria.addSelectColumn(CUSTOMER_ID); 277 criteria.addSelectColumn(RECIPIENT_ID); 278 criteria.addSelectColumn(PROJECT_ID); 279 criteria.addSelectColumn(SORDER_ID); 280 criteria.addSelectColumn(INVOICE_CODE); 281 criteria.addSelectColumn(SUBJECT); 282 criteria.addSelectColumn(NOTES); 283 criteria.addSelectColumn(CREATED); 284 criteria.addSelectColumn(MODIFIED); 285 criteria.addSelectColumn(CREATED_BY); 286 criteria.addSelectColumn(MODIFIED_BY); 287 } 288 289 298 public static Service row2Object(Record row, 299 int offset, 300 Class cls) 301 throws TorqueException 302 { 303 try 304 { 305 Service obj = (Service) cls.newInstance(); 306 ServicePeer.populateObject(row, offset, obj); 307 obj.setModified(false); 308 obj.setNew(false); 309 310 return obj; 311 } 312 catch (InstantiationException e) 313 { 314 throw new TorqueException(e); 315 } 316 catch (IllegalAccessException e) 317 { 318 throw new TorqueException(e); 319 } 320 } 321 322 331 public static void populateObject(Record row, 332 int offset, 333 Service obj) 334 throws TorqueException 335 { 336 try 337 { 338 obj.setServiceId(row.getValue(offset + 0).asInt()); 339 obj.setServiceCode(row.getValue(offset + 1).asString()); 340 obj.setStatus(row.getValue(offset + 2).asInt()); 341 obj.setPriority(row.getValue(offset + 3).asInt()); 342 obj.setIssuedDate(row.getValue(offset + 4).asUtilDate()); 343 obj.setClosedDate(row.getValue(offset + 5).asUtilDate()); 344 obj.setCustomerId(row.getValue(offset + 6).asInt()); 345 obj.setRecipientId(row.getValue(offset + 7).asInt()); 346 obj.setProjectId(row.getValue(offset + 8).asInt()); 347 obj.setSorderId(row.getValue(offset + 9).asInt()); 348 obj.setInvoiceCode(row.getValue(offset + 10).asString()); 349 obj.setSubject(row.getValue(offset + 11).asString()); 350 obj.setNotes(row.getValue(offset + 12).asString()); 351 obj.setCreated(row.getValue(offset + 13).asUtilDate()); 352 obj.setModified(row.getValue(offset + 14).asUtilDate()); 353 obj.setCreatedBy(row.getValue(offset + 15).asString()); 354 obj.setModifiedBy(row.getValue(offset + 16).asString()); 355 } 356 catch (DataSetException e) 357 { 358 throw new TorqueException(e); 359 } 360 } 361 362 370 public static List doSelect(Criteria criteria) throws TorqueException 371 { 372 return populateObjects(doSelectVillageRecords(criteria)); 373 } 374 375 384 public static List doSelect(Criteria criteria, Connection con) 385 throws TorqueException 386 { 387 return populateObjects(doSelectVillageRecords(criteria, con)); 388 } 389 390 400 public static List doSelectVillageRecords(Criteria criteria) 401 throws TorqueException 402 { 403 return BaseServicePeer 404 .doSelectVillageRecords(criteria, (Connection ) null); 405 } 406 407 416 public static List doSelectVillageRecords(Criteria criteria, Connection con) 417 throws TorqueException 418 { 419 if (criteria.getSelectColumns().size() == 0) 420 { 421 addSelectColumns(criteria); 422 } 423 424 425 setDbName(criteria); 426 427 if (con == null) 430 { 431 return BasePeer.doSelect(criteria); 432 } 433 else 434 { 435 return BasePeer.doSelect(criteria, con); 436 } 437 } 438 439 446 public static List populateObjects(List records) 447 throws TorqueException 448 { 449 List results = new ArrayList (records.size()); 450 451 for (int i = 0; i < records.size(); i++) 453 { 454 Record row = (Record) records.get(i); 455 results.add(ServicePeer.row2Object(row, 1, 456 ServicePeer.getOMClass())); 457 } 458 return results; 459 } 460 461 462 470 public static Class getOMClass() 471 throws TorqueException 472 { 473 return CLASS_DEFAULT; 474 } 475 476 484 public static void doUpdate(Criteria criteria) throws TorqueException 485 { 486 BaseServicePeer 487 .doUpdate(criteria, (Connection ) null); 488 } 489 490 501 public static void doUpdate(Criteria criteria, Connection con) 502 throws TorqueException 503 { 504 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 505 selectCriteria.put(SERVICE_ID, criteria.remove(SERVICE_ID)); 506 507 setDbName(criteria); 508 509 if (con == null) 510 { 511 BasePeer.doUpdate(selectCriteria, criteria); 512 } 513 else 514 { 515 BasePeer.doUpdate(selectCriteria, criteria, con); 516 } 517 } 518 519 526 public static void doDelete(Criteria criteria) throws TorqueException 527 { 528 ServicePeer 529 .doDelete(criteria, (Connection ) null); 530 } 531 532 542 public static void doDelete(Criteria criteria, Connection con) 543 throws TorqueException 544 { 545 546 setDbName(criteria); 547 548 if (con == null) 549 { 550 BasePeer.doDelete(criteria); 551 } 552 else 553 { 554 BasePeer.doDelete(criteria, con); 555 } 556 } 557 558 564 public static List doSelect(Service obj) throws TorqueException 565 { 566 return doSelect(buildSelectCriteria(obj)); 567 } 568 569 575 public static void doInsert(Service obj) throws TorqueException 576 { 577 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 578 obj.setNew(false); 579 obj.setModified(false); 580 } 581 582 587 public static void doUpdate(Service obj) throws TorqueException 588 { 589 doUpdate(buildCriteria(obj)); 590 obj.setModified(false); 591 } 592 593 598 public static void doDelete(Service obj) throws TorqueException 599 { 600 doDelete(buildSelectCriteria(obj)); 601 } 602 603 613 public static void doInsert(Service obj, Connection con) 614 throws TorqueException 615 { 616 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 617 obj.setNew(false); 618 obj.setModified(false); 619 } 620 621 631 public static void doUpdate(Service obj, Connection con) 632 throws TorqueException 633 { 634 doUpdate(buildCriteria(obj), con); 635 obj.setModified(false); 636 } 637 638 648 public static void doDelete(Service obj, Connection con) 649 throws TorqueException 650 { 651 doDelete(buildSelectCriteria(obj), con); 652 } 653 654 661 public static void doDelete(ObjectKey pk) throws TorqueException 662 { 663 BaseServicePeer 664 .doDelete(pk, (Connection ) null); 665 } 666 667 677 public static void doDelete(ObjectKey pk, Connection con) 678 throws TorqueException 679 { 680 doDelete(buildCriteria(pk), con); 681 } 682 683 684 public static Criteria buildCriteria( ObjectKey pk ) 685 { 686 Criteria criteria = new Criteria(); 687 criteria.add(SERVICE_ID, pk); 688 return criteria; 689 } 690 691 692 public static Criteria buildCriteria( Service obj ) 693 { 694 Criteria criteria = new Criteria(DATABASE_NAME); 695 if (!obj.isNew()) 696 criteria.add(SERVICE_ID, obj.getServiceId()); 697 criteria.add(SERVICE_CODE, obj.getServiceCode()); 698 criteria.add(STATUS, obj.getStatus()); 699 criteria.add(PRIORITY, obj.getPriority()); 700 criteria.add(ISSUED_DATE, obj.getIssuedDate()); 701 criteria.add(CLOSED_DATE, obj.getClosedDate()); 702 criteria.add(CUSTOMER_ID, obj.getCustomerId()); 703 criteria.add(RECIPIENT_ID, obj.getRecipientId()); 704 criteria.add(PROJECT_ID, obj.getProjectId()); 705 criteria.add(SORDER_ID, obj.getSorderId()); 706 criteria.add(INVOICE_CODE, obj.getInvoiceCode()); 707 criteria.add(SUBJECT, obj.getSubject()); 708 criteria.add(NOTES, obj.getNotes()); 709 criteria.add(CREATED, obj.getCreated()); 710 criteria.add(MODIFIED, obj.getModified()); 711 criteria.add(CREATED_BY, obj.getCreatedBy()); 712 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 713 return criteria; 714 } 715 716 717 public static Criteria buildSelectCriteria( Service obj ) 718 { 719 Criteria criteria = new Criteria(DATABASE_NAME); 720 if (!obj.isNew()) 721 criteria.add(SERVICE_ID, obj.getServiceId()); 722 criteria.add(SERVICE_CODE, obj.getServiceCode()); 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(RECIPIENT_ID, obj.getRecipientId()); 729 criteria.add(PROJECT_ID, obj.getProjectId()); 730 criteria.add(SORDER_ID, obj.getSorderId()); 731 criteria.add(INVOICE_CODE, obj.getInvoiceCode()); 732 criteria.add(SUBJECT, obj.getSubject()); 733 criteria.add(NOTES, obj.getNotes()); 734 criteria.add(CREATED, obj.getCreated()); 735 criteria.add(MODIFIED, obj.getModified()); 736 criteria.add(CREATED_BY, obj.getCreatedBy()); 737 criteria.add(MODIFIED_BY, obj.getModifiedBy()); 738 return criteria; 739 } 740 741 742 751 public static Service retrieveByPK(int pk) 752 throws TorqueException, NoRowsException, TooManyRowsException 753 { 754 return retrieveByPK(SimpleKey.keyFor(pk)); 755 } 756 757 767 public static Service retrieveByPK(int pk, Connection con) 768 throws TorqueException, NoRowsException, TooManyRowsException 769 { 770 return retrieveByPK(SimpleKey.keyFor(pk), con); 771 } 772 773 782 public static Service retrieveByPK(ObjectKey pk) 783 throws TorqueException, NoRowsException, TooManyRowsException 784 { 785 Connection db = null; 786 Service retVal = null; 787 try 788 { 789 db = Torque.getConnection(DATABASE_NAME); 790 retVal = retrieveByPK(pk, db); 791 } 792 finally 793 { 794 Torque.closeConnection(db); 795 } 796 return(retVal); 797 } 798 799 809 public static Service retrieveByPK(ObjectKey pk, Connection con) 810 throws TorqueException, NoRowsException, TooManyRowsException 811 { 812 Criteria criteria = buildCriteria(pk); 813 List v = doSelect(criteria, con); 814 if (v.size() == 0) 815 { 816 throw new NoRowsException("Failed to select a row."); 817 } 818 else if (v.size() > 1) 819 { 820 throw new TooManyRowsException("Failed to select only one row."); 821 } 822 else 823 { 824 return (Service)v.get(0); 825 } 826 } 827 828 835 public static List retrieveByPKs(List pks) 836 throws TorqueException 837 { 838 Connection db = null; 839 List retVal = null; 840 try 841 { 842 db = Torque.getConnection(DATABASE_NAME); 843 retVal = retrieveByPKs(pks, db); 844 } 845 finally 846 { 847 Torque.closeConnection(db); 848 } 849 return(retVal); 850 } 851 852 860 public static List retrieveByPKs( List pks, Connection dbcon ) 861 throws TorqueException 862 { 863 List objs = null; 864 if (pks == null || pks.size() == 0) 865 { 866 objs = new LinkedList (); 867 } 868 else 869 { 870 Criteria criteria = new Criteria(); 871 criteria.addIn( SERVICE_ID, pks ); 872 objs = doSelect(criteria, dbcon); 873 } 874 return objs; 875 } 876 877 878 879 880 881 882 883 884 885 886 897 protected static List doSelectJoinCustomerRelatedByCustomerId(Criteria criteria) 898 throws TorqueException 899 { 900 setDbName(criteria); 901 902 ServicePeer.addSelectColumns(criteria); 903 int offset = numColumns + 1; 904 CustomerPeer.addSelectColumns(criteria); 905 906 907 criteria.addJoin(ServicePeer.CUSTOMER_ID, 908 CustomerPeer.CUSTOMER_ID); 909 910 911 912 List rows = BasePeer.doSelect(criteria); 913 List results = new ArrayList (); 914 915 for (int i = 0; i < rows.size(); i++) 916 { 917 Record row = (Record) rows.get(i); 918 919 Class omClass = ServicePeer.getOMClass(); 920 Service obj1 = (Service) ServicePeer 921 .row2Object(row, 1, omClass); 922 omClass = CustomerPeer.getOMClass(); 923 Customer obj2 = (Customer)CustomerPeer 924 .row2Object(row, offset, omClass); 925 926 boolean newObject = true; 927 for (int j = 0; j < results.size(); j++) 928 { 929 Service temp_obj1 = (Service)results.get(j); 930 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 931 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 932 { 933 newObject = false; 934 temp_obj2.addServiceRelatedByCustomerId(obj1); 935 break; 936 } 937 } 938 if (newObject) 939 { 940 obj2.initServicesRelatedByCustomerId(); 941 obj2.addServiceRelatedByCustomerId(obj1); 942 } 943 results.add(obj1); 944 } 945 return results; 946 } 947 948 949 950 951 962 protected static List doSelectJoinCustomerRelatedByRecipientId(Criteria criteria) 963 throws TorqueException 964 { 965 setDbName(criteria); 966 967 ServicePeer.addSelectColumns(criteria); 968 int offset = numColumns + 1; 969 CustomerPeer.addSelectColumns(criteria); 970 971 972 criteria.addJoin(ServicePeer.RECIPIENT_ID, 973 CustomerPeer.CUSTOMER_ID); 974 975 976 977 List rows = BasePeer.doSelect(criteria); 978 List results = new ArrayList (); 979 980 for (int i = 0; i < rows.size(); i++) 981 { 982 Record row = (Record) rows.get(i); 983 984 Class omClass = ServicePeer.getOMClass(); 985 Service obj1 = (Service) ServicePeer 986 .row2Object(row, 1, omClass); 987 omClass = CustomerPeer.getOMClass(); 988 Customer obj2 = (Customer)CustomerPeer 989 .row2Object(row, offset, omClass); 990 991 boolean newObject = true; 992 for (int j = 0; j < results.size(); j++) 993 { 994 Service temp_obj1 = (Service)results.get(j); 995 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 996 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 997 { 998 newObject = false; 999 temp_obj2.addServiceRelatedByRecipientId(obj1); 1000 break; 1001 } 1002 } 1003 if (newObject) 1004 { 1005 obj2.initServicesRelatedByRecipientId(); 1006 obj2.addServiceRelatedByRecipientId(obj1); 1007 } 1008 results.add(obj1); 1009 } 1010 return results; 1011 } 1012 1013 1014 1015 1016 1027 protected static List doSelectJoinProject(Criteria criteria) 1028 throws TorqueException 1029 { 1030 setDbName(criteria); 1031 1032 ServicePeer.addSelectColumns(criteria); 1033 int offset = numColumns + 1; 1034 ProjectPeer.addSelectColumns(criteria); 1035 1036 1037 criteria.addJoin(ServicePeer.PROJECT_ID, 1038 ProjectPeer.PROJECT_ID); 1039 1040 1041 1042 List rows = BasePeer.doSelect(criteria); 1043 List results = new ArrayList (); 1044 1045 for (int i = 0; i < rows.size(); i++) 1046 { 1047 Record row = (Record) rows.get(i); 1048 1049 Class omClass = ServicePeer.getOMClass(); 1050 Service obj1 = (Service) ServicePeer 1051 .row2Object(row, 1, omClass); 1052 omClass = ProjectPeer.getOMClass(); 1053 Project obj2 = (Project)ProjectPeer 1054 .row2Object(row, offset, omClass); 1055 1056 boolean newObject = true; 1057 for (int j = 0; j < results.size(); j++) 1058 { 1059 Service temp_obj1 = (Service)results.get(j); 1060 Project temp_obj2 = (Project)temp_obj1.getProject(); 1061 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1062 { 1063 newObject = false; 1064 temp_obj2.addService(obj1); 1065 break; 1066 } 1067 } 1068 if (newObject) 1069 { 1070 obj2.initServices(); 1071 obj2.addService(obj1); 1072 } 1073 results.add(obj1); 1074 } 1075 return results; 1076 } 1077 1078 1079 1080 1081 1092 protected static List doSelectJoinSorder(Criteria criteria) 1093 throws TorqueException 1094 { 1095 setDbName(criteria); 1096 1097 ServicePeer.addSelectColumns(criteria); 1098 int offset = numColumns + 1; 1099 SorderPeer.addSelectColumns(criteria); 1100 1101 1102 criteria.addJoin(ServicePeer.SORDER_ID, 1103 SorderPeer.SORDER_ID); 1104 1105 1106 1107 List rows = BasePeer.doSelect(criteria); 1108 List results = new ArrayList (); 1109 1110 for (int i = 0; i < rows.size(); i++) 1111 { 1112 Record row = (Record) rows.get(i); 1113 1114 Class omClass = ServicePeer.getOMClass(); 1115 Service obj1 = (Service) ServicePeer 1116 .row2Object(row, 1, omClass); 1117 omClass = SorderPeer.getOMClass(); 1118 Sorder obj2 = (Sorder)SorderPeer 1119 .row2Object(row, offset, omClass); 1120 1121 boolean newObject = true; 1122 for (int j = 0; j < results.size(); j++) 1123 { 1124 Service temp_obj1 = (Service)results.get(j); 1125 Sorder temp_obj2 = (Sorder)temp_obj1.getSorder(); 1126 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1127 { 1128 newObject = false; 1129 temp_obj2.addService(obj1); 1130 break; 1131 } 1132 } 1133 if (newObject) 1134 { 1135 obj2.initServices(); 1136 obj2.addService(obj1); 1137 } 1138 results.add(obj1); 1139 } 1140 return results; 1141 } 1142 1143 1144 1145 1146 1147 1148 1149 1150 1161 protected static List doSelectJoinAllExceptCustomerRelatedByCustomerId(Criteria criteria) 1162 throws TorqueException 1163 { 1164 setDbName(criteria); 1165 1166 addSelectColumns(criteria); 1167 int offset2 = numColumns + 1; 1168 1169 1170 1171 ProjectPeer.addSelectColumns(criteria); 1172 int offset3 = offset2 + ProjectPeer.numColumns; 1173 1174 SorderPeer.addSelectColumns(criteria); 1175 int offset4 = offset3 + SorderPeer.numColumns; 1176 1177 List rows = BasePeer.doSelect(criteria); 1178 List results = new ArrayList (); 1179 1180 for (int i = 0; i < rows.size(); i++) 1181 { 1182 Record row = (Record)rows.get(i); 1183 1184 Class omClass = ServicePeer.getOMClass(); 1185 Service obj1 = (Service)ServicePeer 1186 .row2Object(row, 1, omClass); 1187 1188 1189 1190 1191 1192 1193 omClass = ProjectPeer.getOMClass(); 1194 Project obj2 = (Project)ProjectPeer 1195 .row2Object( row, offset2, omClass); 1196 1197 boolean newObject = true; 1198 for (int j = 0; j < results.size(); j++) 1199 { 1200 Service temp_obj1 = (Service)results.get(j); 1201 Project temp_obj2 = (Project)temp_obj1.getProject(); 1202 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1203 { 1204 newObject = false; 1205 temp_obj2.addService(obj1); 1206 break; 1207 } 1208 } 1209 if (newObject) 1210 { 1211 obj2.initServices(); 1212 obj2.addService(obj1); 1213 } 1214 1215 1216 1217 1218 omClass = SorderPeer.getOMClass(); 1219 Sorder obj3 = (Sorder)SorderPeer 1220 .row2Object( row, offset3, omClass); 1221 1222 newObject = true; 1223 for (int j = 0; j < results.size(); j++) 1224 { 1225 Service temp_obj1 = (Service)results.get(j); 1226 Sorder temp_obj3 = (Sorder)temp_obj1.getSorder(); 1227 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1228 { 1229 newObject = false; 1230 temp_obj3.addService(obj1); 1231 break; 1232 } 1233 } 1234 if (newObject) 1235 { 1236 obj3.initServices(); 1237 obj3.addService(obj1); 1238 } 1239 results.add(obj1); 1240 } 1241 return results; 1242 } 1243 1244 1245 1246 1247 1248 1259 protected static List doSelectJoinAllExceptCustomerRelatedByRecipientId(Criteria criteria) 1260 throws TorqueException 1261 { 1262 setDbName(criteria); 1263 1264 addSelectColumns(criteria); 1265 int offset2 = numColumns + 1; 1266 1267 1268 1269 ProjectPeer.addSelectColumns(criteria); 1270 int offset3 = offset2 + ProjectPeer.numColumns; 1271 1272 SorderPeer.addSelectColumns(criteria); 1273 int offset4 = offset3 + SorderPeer.numColumns; 1274 1275 List rows = BasePeer.doSelect(criteria); 1276 List results = new ArrayList (); 1277 1278 for (int i = 0; i < rows.size(); i++) 1279 { 1280 Record row = (Record)rows.get(i); 1281 1282 Class omClass = ServicePeer.getOMClass(); 1283 Service obj1 = (Service)ServicePeer 1284 .row2Object(row, 1, omClass); 1285 1286 1287 1288 1289 1290 1291 omClass = ProjectPeer.getOMClass(); 1292 Project obj2 = (Project)ProjectPeer 1293 .row2Object( row, offset2, omClass); 1294 1295 boolean newObject = true; 1296 for (int j = 0; j < results.size(); j++) 1297 { 1298 Service temp_obj1 = (Service)results.get(j); 1299 Project temp_obj2 = (Project)temp_obj1.getProject(); 1300 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1301 { 1302 newObject = false; 1303 temp_obj2.addService(obj1); 1304 break; 1305 } 1306 } 1307 if (newObject) 1308 { 1309 obj2.initServices(); 1310 obj2.addService(obj1); 1311 } 1312 1313 1314 1315 1316 omClass = SorderPeer.getOMClass(); 1317 Sorder obj3 = (Sorder)SorderPeer 1318 .row2Object( row, offset3, omClass); 1319 1320 newObject = true; 1321 for (int j = 0; j < results.size(); j++) 1322 { 1323 Service temp_obj1 = (Service)results.get(j); 1324 Sorder temp_obj3 = (Sorder)temp_obj1.getSorder(); 1325 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1326 { 1327 newObject = false; 1328 temp_obj3.addService(obj1); 1329 break; 1330 } 1331 } 1332 if (newObject) 1333 { 1334 obj3.initServices(); 1335 obj3.addService(obj1); 1336 } 1337 results.add(obj1); 1338 } 1339 return results; 1340 } 1341 1342 1343 1344 1345 1346 1357 protected static List doSelectJoinAllExceptProject(Criteria criteria) 1358 throws TorqueException 1359 { 1360 setDbName(criteria); 1361 1362 addSelectColumns(criteria); 1363 int offset2 = numColumns + 1; 1364 1365 CustomerPeer.addSelectColumns(criteria); 1366 int offset3 = offset2 + CustomerPeer.numColumns; 1367 1368 CustomerPeer.addSelectColumns(criteria); 1369 int offset4 = offset3 + CustomerPeer.numColumns; 1370 1371 1372 SorderPeer.addSelectColumns(criteria); 1373 int offset5 = offset4 + SorderPeer.numColumns; 1374 1375 List rows = BasePeer.doSelect(criteria); 1376 List results = new ArrayList (); 1377 1378 for (int i = 0; i < rows.size(); i++) 1379 { 1380 Record row = (Record)rows.get(i); 1381 1382 Class omClass = ServicePeer.getOMClass(); 1383 Service obj1 = (Service)ServicePeer 1384 .row2Object(row, 1, omClass); 1385 1386 1387 1388 1389 omClass = CustomerPeer.getOMClass(); 1390 Customer obj2 = (Customer)CustomerPeer 1391 .row2Object( row, offset2, omClass); 1392 1393 boolean newObject = true; 1394 for (int j = 0; j < results.size(); j++) 1395 { 1396 Service temp_obj1 = (Service)results.get(j); 1397 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 1398 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1399 { 1400 newObject = false; 1401 temp_obj2.addServiceRelatedByCustomerId(obj1); 1402 break; 1403 } 1404 } 1405 if (newObject) 1406 { 1407 obj2.initServicesRelatedByCustomerId(); 1408 obj2.addServiceRelatedByCustomerId(obj1); 1409 } 1410 1411 1412 1413 1414 omClass = CustomerPeer.getOMClass(); 1415 Customer obj3 = (Customer)CustomerPeer 1416 .row2Object( row, offset3, omClass); 1417 1418 newObject = true; 1419 for (int j = 0; j < results.size(); j++) 1420 { 1421 Service temp_obj1 = (Service)results.get(j); 1422 Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 1423 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1424 { 1425 newObject = false; 1426 temp_obj3.addServiceRelatedByRecipientId(obj1); 1427 break; 1428 } 1429 } 1430 if (newObject) 1431 { 1432 obj3.initServicesRelatedByRecipientId(); 1433 obj3.addServiceRelatedByRecipientId(obj1); 1434 } 1435 1436 1437 1438 1439 1440 omClass = SorderPeer.getOMClass(); 1441 Sorder obj4 = (Sorder)SorderPeer 1442 .row2Object( row, offset4, omClass); 1443 1444 newObject = true; 1445 for (int j = 0; j < results.size(); j++) 1446 { 1447 Service temp_obj1 = (Service)results.get(j); 1448 Sorder temp_obj4 = (Sorder)temp_obj1.getSorder(); 1449 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1450 { 1451 newObject = false; 1452 temp_obj4.addService(obj1); 1453 break; 1454 } 1455 } 1456 if (newObject) 1457 { 1458 obj4.initServices(); 1459 obj4.addService(obj1); 1460 } 1461 results.add(obj1); 1462 } 1463 return results; 1464 } 1465 1466 1467 1468 1469 1470 1481 protected static List doSelectJoinAllExceptSorder(Criteria criteria) 1482 throws TorqueException 1483 { 1484 setDbName(criteria); 1485 1486 addSelectColumns(criteria); 1487 int offset2 = numColumns + 1; 1488 1489 CustomerPeer.addSelectColumns(criteria); 1490 int offset3 = offset2 + CustomerPeer.numColumns; 1491 1492 CustomerPeer.addSelectColumns(criteria); 1493 int offset4 = offset3 + CustomerPeer.numColumns; 1494 1495 ProjectPeer.addSelectColumns(criteria); 1496 int offset5 = offset4 + ProjectPeer.numColumns; 1497 1498 1499 List rows = BasePeer.doSelect(criteria); 1500 List results = new ArrayList (); 1501 1502 for (int i = 0; i < rows.size(); i++) 1503 { 1504 Record row = (Record)rows.get(i); 1505 1506 Class omClass = ServicePeer.getOMClass(); 1507 Service obj1 = (Service)ServicePeer 1508 .row2Object(row, 1, omClass); 1509 1510 1511 1512 1513 omClass = CustomerPeer.getOMClass(); 1514 Customer obj2 = (Customer)CustomerPeer 1515 .row2Object( row, offset2, omClass); 1516 1517 boolean newObject = true; 1518 for (int j = 0; j < results.size(); j++) 1519 { 1520 Service temp_obj1 = (Service)results.get(j); 1521 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId(); 1522 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1523 { 1524 newObject = false; 1525 temp_obj2.addServiceRelatedByCustomerId(obj1); 1526 break; 1527 } 1528 } 1529 if (newObject) 1530 { 1531 obj2.initServicesRelatedByCustomerId(); 1532 obj2.addServiceRelatedByCustomerId(obj1); 1533 } 1534 1535 1536 1537 1538 omClass = CustomerPeer.getOMClass(); 1539 Customer obj3 = (Customer)CustomerPeer 1540 .row2Object( row, offset3, omClass); 1541 1542 newObject = true; 1543 for (int j = 0; j < results.size(); j++) 1544 { 1545 Service temp_obj1 = (Service)results.get(j); 1546 Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId(); 1547 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1548 { 1549 newObject = false; 1550 temp_obj3.addServiceRelatedByRecipientId(obj1); 1551 break; 1552 } 1553 } 1554 if (newObject) 1555 { 1556 obj3.initServicesRelatedByRecipientId(); 1557 obj3.addServiceRelatedByRecipientId(obj1); 1558 } 1559 1560 1561 1562 1563 omClass = ProjectPeer.getOMClass(); 1564 Project obj4 = (Project)ProjectPeer 1565 .row2Object( row, offset4, omClass); 1566 1567 newObject = true; 1568 for (int j = 0; j < results.size(); j++) 1569 { 1570 Service temp_obj1 = (Service)results.get(j); 1571 Project temp_obj4 = (Project)temp_obj1.getProject(); 1572 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1573 { 1574 newObject = false; 1575 temp_obj4.addService(obj1); 1576 break; 1577 } 1578 } 1579 if (newObject) 1580 { 1581 obj4.initServices(); 1582 obj4.addService(obj1); 1583 } 1584 1585 results.add(obj1); 1586 } 1587 return results; 1588 } 1589 1590 1591 1598 protected static TableMap getTableMap() 1599 throws TorqueException 1600 { 1601 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1602 } 1603 1604 private static void setDbName(Criteria crit) 1605 { 1606 if (crit.getDbName() == Torque.getDefaultDB()) 1610 { 1611 crit.setDbName(DATABASE_NAME); 1612 } 1613 } 1614} 1615
| Popular Tags
|