1 package org.tigris.scarab.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.tigris.scarab.om.map.*; 32 33 34 35 36 37 39 public abstract class BaseActivitySetPeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_TRANSACTION"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(ActivitySetMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String TRANSACTION_ID; 62 63 public static final String TYPE_ID; 64 65 public static final String ATTACHMENT_ID; 66 67 public static final String CREATED_BY; 68 69 public static final String CREATED_DATE; 70 71 static 72 { 73 TRANSACTION_ID = "SCARAB_TRANSACTION.TRANSACTION_ID"; 74 TYPE_ID = "SCARAB_TRANSACTION.TYPE_ID"; 75 ATTACHMENT_ID = "SCARAB_TRANSACTION.ATTACHMENT_ID"; 76 CREATED_BY = "SCARAB_TRANSACTION.CREATED_BY"; 77 CREATED_DATE = "SCARAB_TRANSACTION.CREATED_DATE"; 78 if (Torque.isInit()) 79 { 80 try 81 { 82 getMapBuilder(ActivitySetMapBuilder.CLASS_NAME); 83 } 84 catch (Exception e) 85 { 86 log.error("Could not initialize Peer", e); 87 } 88 } 89 else 90 { 91 Torque.registerMapBuilder(ActivitySetMapBuilder.CLASS_NAME); 92 } 93 } 94 95 96 public static final int numColumns = 5; 97 98 99 protected static final String CLASSNAME_DEFAULT = 100 "org.tigris.scarab.om.ActivitySet"; 101 102 103 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 104 105 111 private static Class initClass(String className) 112 { 113 Class c = null; 114 try 115 { 116 c = Class.forName(className); 117 } 118 catch (Throwable t) 119 { 120 log.error("A FATAL ERROR has occurred which should not " 121 + "have happened under any circumstance. Please notify " 122 + "the Torque developers <torque-dev@db.apache.org> " 123 + "and give as many details as possible (including the error " 124 + "stack trace).", t); 125 126 if (t instanceof Error ) 128 { 129 throw (Error ) t.fillInStackTrace(); 130 } 131 } 132 return c; 133 } 134 135 145 public static List resultSet2Objects(java.sql.ResultSet results) 146 throws TorqueException 147 { 148 try 149 { 150 QueryDataSet qds = null; 151 List rows = null; 152 try 153 { 154 qds = new QueryDataSet(results); 155 rows = getSelectResults(qds); 156 } 157 finally 158 { 159 if (qds != null) 160 { 161 qds.close(); 162 } 163 } 164 165 return populateObjects(rows); 166 } 167 catch (SQLException e) 168 { 169 throw new TorqueException(e); 170 } 171 catch (DataSetException e) 172 { 173 throw new TorqueException(e); 174 } 175 } 176 177 178 179 186 public static ObjectKey doInsert(Criteria criteria) 187 throws TorqueException 188 { 189 return BaseActivitySetPeer 190 .doInsert(criteria, (Connection ) null); 191 } 192 193 203 public static ObjectKey doInsert(Criteria criteria, Connection con) 204 throws TorqueException 205 { 206 207 setDbName(criteria); 208 209 if (con == null) 210 { 211 return BasePeer.doInsert(criteria); 212 } 213 else 214 { 215 return BasePeer.doInsert(criteria, con); 216 } 217 } 218 219 226 public static void addSelectColumns(Criteria criteria) 227 throws TorqueException 228 { 229 criteria.addSelectColumn(TRANSACTION_ID); 230 criteria.addSelectColumn(TYPE_ID); 231 criteria.addSelectColumn(ATTACHMENT_ID); 232 criteria.addSelectColumn(CREATED_BY); 233 criteria.addSelectColumn(CREATED_DATE); 234 } 235 236 245 public static ActivitySet row2Object(Record row, 246 int offset, 247 Class cls) 248 throws TorqueException 249 { 250 try 251 { 252 ActivitySet obj = (ActivitySet) cls.newInstance(); 253 ActivitySetPeer.populateObject(row, offset, obj); 254 obj.setModified(false); 255 obj.setNew(false); 256 257 return obj; 258 } 259 catch (InstantiationException e) 260 { 261 throw new TorqueException(e); 262 } 263 catch (IllegalAccessException e) 264 { 265 throw new TorqueException(e); 266 } 267 } 268 269 278 public static void populateObject(Record row, 279 int offset, 280 ActivitySet obj) 281 throws TorqueException 282 { 283 try 284 { 285 obj.setActivitySetId(row.getValue(offset + 0).asLongObj()); 286 obj.setTypeId(row.getValue(offset + 1).asIntegerObj()); 287 obj.setAttachmentId(row.getValue(offset + 2).asLongObj()); 288 obj.setCreatedBy(row.getValue(offset + 3).asIntegerObj()); 289 obj.setCreatedDate(row.getValue(offset + 4).asUtilDate()); 290 } 291 catch (DataSetException e) 292 { 293 throw new TorqueException(e); 294 } 295 } 296 297 305 public static List doSelect(Criteria criteria) throws TorqueException 306 { 307 return populateObjects(doSelectVillageRecords(criteria)); 308 } 309 310 319 public static List doSelect(Criteria criteria, Connection con) 320 throws TorqueException 321 { 322 return populateObjects(doSelectVillageRecords(criteria, con)); 323 } 324 325 335 public static List doSelectVillageRecords(Criteria criteria) 336 throws TorqueException 337 { 338 return BaseActivitySetPeer 339 .doSelectVillageRecords(criteria, (Connection ) null); 340 } 341 342 351 public static List doSelectVillageRecords(Criteria criteria, Connection con) 352 throws TorqueException 353 { 354 if (criteria.getSelectColumns().size() == 0) 355 { 356 addSelectColumns(criteria); 357 } 358 359 360 setDbName(criteria); 361 362 if (con == null) 365 { 366 return BasePeer.doSelect(criteria); 367 } 368 else 369 { 370 return BasePeer.doSelect(criteria, con); 371 } 372 } 373 374 381 public static List populateObjects(List records) 382 throws TorqueException 383 { 384 List results = new ArrayList (records.size()); 385 386 for (int i = 0; i < records.size(); i++) 388 { 389 Record row = (Record) records.get(i); 390 results.add(ActivitySetPeer.row2Object(row, 1, 391 ActivitySetPeer.getOMClass())); 392 } 393 return results; 394 } 395 396 397 405 public static Class getOMClass() 406 throws TorqueException 407 { 408 return CLASS_DEFAULT; 409 } 410 411 419 public static void doUpdate(Criteria criteria) throws TorqueException 420 { 421 BaseActivitySetPeer 422 .doUpdate(criteria, (Connection ) null); 423 } 424 425 436 public static void doUpdate(Criteria criteria, Connection con) 437 throws TorqueException 438 { 439 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 440 selectCriteria.put(TRANSACTION_ID, criteria.remove(TRANSACTION_ID)); 441 442 setDbName(criteria); 443 444 if (con == null) 445 { 446 BasePeer.doUpdate(selectCriteria, criteria); 447 } 448 else 449 { 450 BasePeer.doUpdate(selectCriteria, criteria, con); 451 } 452 } 453 454 461 public static void doDelete(Criteria criteria) throws TorqueException 462 { 463 ActivitySetPeer 464 .doDelete(criteria, (Connection ) null); 465 } 466 467 477 public static void doDelete(Criteria criteria, Connection con) 478 throws TorqueException 479 { 480 481 setDbName(criteria); 482 483 if (con == null) 484 { 485 BasePeer.doDelete(criteria); 486 } 487 else 488 { 489 BasePeer.doDelete(criteria, con); 490 } 491 } 492 493 499 public static List doSelect(ActivitySet obj) throws TorqueException 500 { 501 return doSelect(buildSelectCriteria(obj)); 502 } 503 504 510 public static void doInsert(ActivitySet obj) throws TorqueException 511 { 512 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 513 obj.setNew(false); 514 obj.setModified(false); 515 } 516 517 522 public static void doUpdate(ActivitySet obj) throws TorqueException 523 { 524 doUpdate(buildCriteria(obj)); 525 obj.setModified(false); 526 } 527 528 533 public static void doDelete(ActivitySet obj) throws TorqueException 534 { 535 doDelete(buildSelectCriteria(obj)); 536 } 537 538 548 public static void doInsert(ActivitySet obj, Connection con) 549 throws TorqueException 550 { 551 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 552 obj.setNew(false); 553 obj.setModified(false); 554 } 555 556 566 public static void doUpdate(ActivitySet obj, Connection con) 567 throws TorqueException 568 { 569 doUpdate(buildCriteria(obj), con); 570 obj.setModified(false); 571 } 572 573 583 public static void doDelete(ActivitySet obj, Connection con) 584 throws TorqueException 585 { 586 doDelete(buildSelectCriteria(obj), con); 587 } 588 589 596 public static void doDelete(ObjectKey pk) throws TorqueException 597 { 598 BaseActivitySetPeer 599 .doDelete(pk, (Connection ) null); 600 } 601 602 612 public static void doDelete(ObjectKey pk, Connection con) 613 throws TorqueException 614 { 615 doDelete(buildCriteria(pk), con); 616 } 617 618 619 public static Criteria buildCriteria( ObjectKey pk ) 620 { 621 Criteria criteria = new Criteria(); 622 criteria.add(TRANSACTION_ID, pk); 623 return criteria; 624 } 625 626 627 public static Criteria buildCriteria( ActivitySet obj ) 628 { 629 Criteria criteria = new Criteria(DATABASE_NAME); 630 if (!obj.isNew()) 631 criteria.add(TRANSACTION_ID, obj.getActivitySetId()); 632 criteria.add(TYPE_ID, obj.getTypeId()); 633 criteria.add(ATTACHMENT_ID, obj.getAttachmentId()); 634 criteria.add(CREATED_BY, obj.getCreatedBy()); 635 criteria.add(CREATED_DATE, obj.getCreatedDate()); 636 return criteria; 637 } 638 639 640 public static Criteria buildSelectCriteria( ActivitySet obj ) 641 { 642 Criteria criteria = new Criteria(DATABASE_NAME); 643 if (!obj.isNew()) 644 criteria.add(TRANSACTION_ID, obj.getActivitySetId()); 645 criteria.add(TYPE_ID, obj.getTypeId()); 646 criteria.add(ATTACHMENT_ID, obj.getAttachmentId()); 647 criteria.add(CREATED_BY, obj.getCreatedBy()); 648 criteria.add(CREATED_DATE, obj.getCreatedDate()); 649 return criteria; 650 } 651 652 653 662 public static ActivitySet retrieveByPK(Long pk) 663 throws TorqueException, NoRowsException, TooManyRowsException 664 { 665 return retrieveByPK(SimpleKey.keyFor(pk)); 666 } 667 668 678 public static ActivitySet retrieveByPK(Long pk, Connection con) 679 throws TorqueException, NoRowsException, TooManyRowsException 680 { 681 return retrieveByPK(SimpleKey.keyFor(pk), con); 682 } 683 684 693 public static ActivitySet retrieveByPK(ObjectKey pk) 694 throws TorqueException, NoRowsException, TooManyRowsException 695 { 696 Connection db = null; 697 ActivitySet retVal = null; 698 try 699 { 700 db = Torque.getConnection(DATABASE_NAME); 701 retVal = retrieveByPK(pk, db); 702 } 703 finally 704 { 705 Torque.closeConnection(db); 706 } 707 return(retVal); 708 } 709 710 720 public static ActivitySet retrieveByPK(ObjectKey pk, Connection con) 721 throws TorqueException, NoRowsException, TooManyRowsException 722 { 723 Criteria criteria = buildCriteria(pk); 724 List v = doSelect(criteria, con); 725 if (v.size() == 0) 726 { 727 throw new NoRowsException("Failed to select a row."); 728 } 729 else if (v.size() > 1) 730 { 731 throw new TooManyRowsException("Failed to select only one row."); 732 } 733 else 734 { 735 return (ActivitySet)v.get(0); 736 } 737 } 738 739 746 public static List retrieveByPKs(List pks) 747 throws TorqueException 748 { 749 Connection db = null; 750 List retVal = null; 751 try 752 { 753 db = Torque.getConnection(DATABASE_NAME); 754 retVal = retrieveByPKs(pks, db); 755 } 756 finally 757 { 758 Torque.closeConnection(db); 759 } 760 return(retVal); 761 } 762 763 771 public static List retrieveByPKs( List pks, Connection dbcon ) 772 throws TorqueException 773 { 774 List objs = null; 775 if (pks == null || pks.size() == 0) 776 { 777 objs = new LinkedList (); 778 } 779 else 780 { 781 Criteria criteria = new Criteria(); 782 criteria.addIn( TRANSACTION_ID, pks ); 783 objs = doSelect(criteria, dbcon); 784 } 785 return objs; 786 } 787 788 789 790 791 792 793 794 795 796 797 808 protected static List doSelectJoinScarabUserImpl(Criteria criteria) 809 throws TorqueException 810 { 811 setDbName(criteria); 812 813 ActivitySetPeer.addSelectColumns(criteria); 814 int offset = numColumns + 1; 815 ScarabUserImplPeer.addSelectColumns(criteria); 816 817 818 criteria.addJoin(ActivitySetPeer.CREATED_BY, 819 ScarabUserImplPeer.USER_ID); 820 821 822 823 List rows = BasePeer.doSelect(criteria); 824 List results = new ArrayList (); 825 826 for (int i = 0; i < rows.size(); i++) 827 { 828 Record row = (Record) rows.get(i); 829 830 Class omClass = ActivitySetPeer.getOMClass(); 831 ActivitySet obj1 = (ActivitySet) ActivitySetPeer 832 .row2Object(row, 1, omClass); 833 omClass = ScarabUserImplPeer.getOMClass(); 834 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 835 .row2Object(row, offset, omClass); 836 837 boolean newObject = true; 838 for (int j = 0; j < results.size(); j++) 839 { 840 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 841 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 842 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 843 { 844 newObject = false; 845 temp_obj2.addActivitySet(obj1); 846 break; 847 } 848 } 849 if (newObject) 850 { 851 obj2.initActivitySets(); 852 obj2.addActivitySet(obj1); 853 } 854 results.add(obj1); 855 } 856 return results; 857 } 858 859 860 861 862 873 protected static List doSelectJoinActivitySetType(Criteria criteria) 874 throws TorqueException 875 { 876 setDbName(criteria); 877 878 ActivitySetPeer.addSelectColumns(criteria); 879 int offset = numColumns + 1; 880 ActivitySetTypePeer.addSelectColumns(criteria); 881 882 883 criteria.addJoin(ActivitySetPeer.TYPE_ID, 884 ActivitySetTypePeer.TYPE_ID); 885 886 887 888 List rows = BasePeer.doSelect(criteria); 889 List results = new ArrayList (); 890 891 for (int i = 0; i < rows.size(); i++) 892 { 893 Record row = (Record) rows.get(i); 894 895 Class omClass = ActivitySetPeer.getOMClass(); 896 ActivitySet obj1 = (ActivitySet) ActivitySetPeer 897 .row2Object(row, 1, omClass); 898 omClass = ActivitySetTypePeer.getOMClass(); 899 ActivitySetType obj2 = (ActivitySetType)ActivitySetTypePeer 900 .row2Object(row, offset, omClass); 901 902 boolean newObject = true; 903 for (int j = 0; j < results.size(); j++) 904 { 905 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 906 ActivitySetType temp_obj2 = (ActivitySetType)temp_obj1.getActivitySetType(); 907 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 908 { 909 newObject = false; 910 temp_obj2.addActivitySet(obj1); 911 break; 912 } 913 } 914 if (newObject) 915 { 916 obj2.initActivitySets(); 917 obj2.addActivitySet(obj1); 918 } 919 results.add(obj1); 920 } 921 return results; 922 } 923 924 925 926 927 938 protected static List doSelectJoinAttachment(Criteria criteria) 939 throws TorqueException 940 { 941 setDbName(criteria); 942 943 ActivitySetPeer.addSelectColumns(criteria); 944 int offset = numColumns + 1; 945 AttachmentPeer.addSelectColumns(criteria); 946 947 948 criteria.addJoin(ActivitySetPeer.ATTACHMENT_ID, 949 AttachmentPeer.ATTACHMENT_ID); 950 951 952 953 List rows = BasePeer.doSelect(criteria); 954 List results = new ArrayList (); 955 956 for (int i = 0; i < rows.size(); i++) 957 { 958 Record row = (Record) rows.get(i); 959 960 Class omClass = ActivitySetPeer.getOMClass(); 961 ActivitySet obj1 = (ActivitySet) ActivitySetPeer 962 .row2Object(row, 1, omClass); 963 omClass = AttachmentPeer.getOMClass(); 964 Attachment obj2 = (Attachment)AttachmentPeer 965 .row2Object(row, offset, omClass); 966 967 boolean newObject = true; 968 for (int j = 0; j < results.size(); j++) 969 { 970 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 971 Attachment temp_obj2 = (Attachment)temp_obj1.getAttachment(); 972 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 973 { 974 newObject = false; 975 temp_obj2.addActivitySet(obj1); 976 break; 977 } 978 } 979 if (newObject) 980 { 981 obj2.initActivitySets(); 982 obj2.addActivitySet(obj1); 983 } 984 results.add(obj1); 985 } 986 return results; 987 } 988 989 990 991 992 993 994 995 996 1007 protected static List doSelectJoinAllExceptScarabUserImpl(Criteria criteria) 1008 throws TorqueException 1009 { 1010 setDbName(criteria); 1011 1012 addSelectColumns(criteria); 1013 int offset2 = numColumns + 1; 1014 1015 1016 ActivitySetTypePeer.addSelectColumns(criteria); 1017 int offset3 = offset2 + ActivitySetTypePeer.numColumns; 1018 1019 AttachmentPeer.addSelectColumns(criteria); 1020 int offset4 = offset3 + AttachmentPeer.numColumns; 1021 1022 List rows = BasePeer.doSelect(criteria); 1023 List results = new ArrayList (); 1024 1025 for (int i = 0; i < rows.size(); i++) 1026 { 1027 Record row = (Record)rows.get(i); 1028 1029 Class omClass = ActivitySetPeer.getOMClass(); 1030 ActivitySet obj1 = (ActivitySet)ActivitySetPeer 1031 .row2Object(row, 1, omClass); 1032 1033 1034 1035 1036 1037 omClass = ActivitySetTypePeer.getOMClass(); 1038 ActivitySetType obj2 = (ActivitySetType)ActivitySetTypePeer 1039 .row2Object( row, offset2, omClass); 1040 1041 boolean newObject = true; 1042 for (int j = 0; j < results.size(); j++) 1043 { 1044 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 1045 ActivitySetType temp_obj2 = (ActivitySetType)temp_obj1.getActivitySetType(); 1046 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1047 { 1048 newObject = false; 1049 temp_obj2.addActivitySet(obj1); 1050 break; 1051 } 1052 } 1053 if (newObject) 1054 { 1055 obj2.initActivitySets(); 1056 obj2.addActivitySet(obj1); 1057 } 1058 1059 1060 1061 1062 omClass = AttachmentPeer.getOMClass(); 1063 Attachment obj3 = (Attachment)AttachmentPeer 1064 .row2Object( row, offset3, omClass); 1065 1066 newObject = true; 1067 for (int j = 0; j < results.size(); j++) 1068 { 1069 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 1070 Attachment temp_obj3 = (Attachment)temp_obj1.getAttachment(); 1071 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1072 { 1073 newObject = false; 1074 temp_obj3.addActivitySet(obj1); 1075 break; 1076 } 1077 } 1078 if (newObject) 1079 { 1080 obj3.initActivitySets(); 1081 obj3.addActivitySet(obj1); 1082 } 1083 results.add(obj1); 1084 } 1085 return results; 1086 } 1087 1088 1089 1090 1091 1092 1103 protected static List doSelectJoinAllExceptActivitySetType(Criteria criteria) 1104 throws TorqueException 1105 { 1106 setDbName(criteria); 1107 1108 addSelectColumns(criteria); 1109 int offset2 = numColumns + 1; 1110 1111 ScarabUserImplPeer.addSelectColumns(criteria); 1112 int offset3 = offset2 + ScarabUserImplPeer.numColumns; 1113 1114 1115 AttachmentPeer.addSelectColumns(criteria); 1116 int offset4 = offset3 + AttachmentPeer.numColumns; 1117 1118 List rows = BasePeer.doSelect(criteria); 1119 List results = new ArrayList (); 1120 1121 for (int i = 0; i < rows.size(); i++) 1122 { 1123 Record row = (Record)rows.get(i); 1124 1125 Class omClass = ActivitySetPeer.getOMClass(); 1126 ActivitySet obj1 = (ActivitySet)ActivitySetPeer 1127 .row2Object(row, 1, omClass); 1128 1129 1130 1131 1132 omClass = ScarabUserImplPeer.getOMClass(); 1133 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1134 .row2Object( row, offset2, omClass); 1135 1136 boolean newObject = true; 1137 for (int j = 0; j < results.size(); j++) 1138 { 1139 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 1140 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1141 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1142 { 1143 newObject = false; 1144 temp_obj2.addActivitySet(obj1); 1145 break; 1146 } 1147 } 1148 if (newObject) 1149 { 1150 obj2.initActivitySets(); 1151 obj2.addActivitySet(obj1); 1152 } 1153 1154 1155 1156 1157 1158 omClass = AttachmentPeer.getOMClass(); 1159 Attachment obj3 = (Attachment)AttachmentPeer 1160 .row2Object( row, offset3, omClass); 1161 1162 newObject = true; 1163 for (int j = 0; j < results.size(); j++) 1164 { 1165 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 1166 Attachment temp_obj3 = (Attachment)temp_obj1.getAttachment(); 1167 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1168 { 1169 newObject = false; 1170 temp_obj3.addActivitySet(obj1); 1171 break; 1172 } 1173 } 1174 if (newObject) 1175 { 1176 obj3.initActivitySets(); 1177 obj3.addActivitySet(obj1); 1178 } 1179 results.add(obj1); 1180 } 1181 return results; 1182 } 1183 1184 1185 1186 1187 1188 1199 protected static List doSelectJoinAllExceptAttachment(Criteria criteria) 1200 throws TorqueException 1201 { 1202 setDbName(criteria); 1203 1204 addSelectColumns(criteria); 1205 int offset2 = numColumns + 1; 1206 1207 ScarabUserImplPeer.addSelectColumns(criteria); 1208 int offset3 = offset2 + ScarabUserImplPeer.numColumns; 1209 1210 ActivitySetTypePeer.addSelectColumns(criteria); 1211 int offset4 = offset3 + ActivitySetTypePeer.numColumns; 1212 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 = ActivitySetPeer.getOMClass(); 1222 ActivitySet obj1 = (ActivitySet)ActivitySetPeer 1223 .row2Object(row, 1, omClass); 1224 1225 1226 1227 1228 omClass = ScarabUserImplPeer.getOMClass(); 1229 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1230 .row2Object( row, offset2, omClass); 1231 1232 boolean newObject = true; 1233 for (int j = 0; j < results.size(); j++) 1234 { 1235 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 1236 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1237 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1238 { 1239 newObject = false; 1240 temp_obj2.addActivitySet(obj1); 1241 break; 1242 } 1243 } 1244 if (newObject) 1245 { 1246 obj2.initActivitySets(); 1247 obj2.addActivitySet(obj1); 1248 } 1249 1250 1251 1252 1253 omClass = ActivitySetTypePeer.getOMClass(); 1254 ActivitySetType obj3 = (ActivitySetType)ActivitySetTypePeer 1255 .row2Object( row, offset3, omClass); 1256 1257 newObject = true; 1258 for (int j = 0; j < results.size(); j++) 1259 { 1260 ActivitySet temp_obj1 = (ActivitySet)results.get(j); 1261 ActivitySetType temp_obj3 = (ActivitySetType)temp_obj1.getActivitySetType(); 1262 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1263 { 1264 newObject = false; 1265 temp_obj3.addActivitySet(obj1); 1266 break; 1267 } 1268 } 1269 if (newObject) 1270 { 1271 obj3.initActivitySets(); 1272 obj3.addActivitySet(obj1); 1273 } 1274 1275 results.add(obj1); 1276 } 1277 return results; 1278 } 1279 1280 1281 1288 protected static TableMap getTableMap() 1289 throws TorqueException 1290 { 1291 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1292 } 1293 1294 private static void setDbName(Criteria crit) 1295 { 1296 if (crit.getDbName() == Torque.getDefaultDB()) 1300 { 1301 crit.setDbName(DATABASE_NAME); 1302 } 1303 } 1304} 1305 | Popular Tags |